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.
Related question No.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 that0x0024
isRETI
?0x96
), hitting "invalid instructions" stored there.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