2

While running a program compiled in the Arduino IDE 1.8.5 and then using the .ELF file inside LabCenter Proteus 8.0, for an Arduino Nano ATMEL Mega 328P, for a code involving the use of the SoftwareSerial.h Library, hence involving several loops, without user interaction, I am getting the following error:

Invalid opcode 0x0024 at PC=0x0096

Now I am completely lost. According the AVR Instruction Set Manual such opcode should (not sure about this?) be RETI - Return From Interrupt at the Program Line (?) no.150 = 0x096. The full code has 779 lines plus several library calls, and the line 150 happens to fall just before the loop() function (?), which should never repeat, being just a declaration.

So, how should I debug this error? Evidently I am not asking to solve the problem for me but, how should I proceed for debugging it and find the real error?

I have been unable to find in Proteus a tool for "Debug Stop if Error"

I have been unable to isolate the error in a simple way to share. It should be related someway with interruptions used by the library SoftwareSerial.h, because at some modifications of the program, the code freezes at an interruption return. I am working on that, but advancing really slowly actually.

enter image description here enter image description here enter image description here enter image description here

Related question No.1.

6
  • 1
    PC=0x96 has no relation to any lines in your source code. So, no, there's no point in looking at line 150. Line 150 is completely irrelevant here. And where exactly in the manual did you read that 0x0024 is RETI? May 11, 2019 at 2:05
  • I am not understanding the situation for debugging this...
    – Brethlosze
    May 11, 2019 at 2:28
  • 1
    Where's the program? Errors like that might easily be caused by out-of-bounds local array modification. Stack damage smashes the stored function's return address, making it "return" to a completely wrong location (e.g. 0x96), hitting "invalid instructions" stored there. May 11, 2019 at 2:52
  • 1
    PC=0x96 means the program counter is pointing to that memory location and it is trying to execute the instruction at that location ..... the last picture shows code at 0x1ab4
    – jsotola
    May 11, 2019 at 2:54
  • 1
    I have the same problem. Would you tell me please, if you have solved the problem, and how?
    – Rami Ma
    Dec 10, 2020 at 10:39

2 Answers 2

2

First: Use the ino.hex file instead of the .ELF file Second: this error is showing because you are compiling your code with a different board. Make sure you are using the correct board over at the Arduino IDE. My advice is: switch your board to Arduino Uno both in proteus and over at the Arduino IDE and see if it works. Later on, you can try different boards.

2

Guys if you are facing the error of invalid opcode 0xffff at pc = 0x3e402 in proteus using Arduino, the GO to Arduino IDE software, and from the top menu, click on 'tool' and change the board type, e.g., Arduino UNO to Arduino Mega 2560.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.