Forum breadcrumbs - You are here:ForumGeneral: Report BugsAVR Invalid instruction
You need to log in to create posts and topics.

AVR Invalid instruction

Hello everyone!

I wanted to report the following BUG:

"ERROR: AVR Invalid instruction: ELPM with no RAMPZ"

SimulIDE:
1.1.0 rev 2068
1.1.0 rev 1909

Version:
WINDOWS 64

Microcontroller:
ATMEGA 1284

The error occurs when trying to use a class in C++

I'M GOING:
MICROCHIP STUDIO 7.0.2594

Compiler:
AVR-GCC

The same HEX file loaded into the physical microcontroller works properly. It also runs correctly in the MICROCHIP STUDIO simulator and debugs correctly.

Regards...

PS. Sorry for any mistakes (google translate)

Uploaded files:

Hi.

Seems that RAMPZ register is missing from atmega1284.

Please try this and let me know if the program is working:
Edit file data/AVR/mega1284 and add this at line 7:

    <regblock  name="I/O_REG" start="0x003B" end="0x003B" offset="32">
      <register  name="RAMPZ" addr="0x003B" bits="" />
    </regblock>

 

The file should look like this:

<!DOCTYPE SimulIDE>

<mcu name="mega1284" core="AVR" data="16640" prog="131072" progword="2" eeprom="4096" inst_cycle="1" freq="16000000" >

    <include file="avr/avr_gpr.xml" />
    <include file="megaxx4/mxx4_regs.xml" />
    <regblock  name="I/O_REG" start="0x003B" end="0x003B" offset="32">
      <register  name="RAMPZ" addr="0x003B" bits="" />
    </regblock>
    
    <datablock name="RAM" start="0x0100" end="0x40FF"/>

    <include file="megaxx4/mxx4_int.xml" />
    <include file="megaxx4/mxx4_perif.xml" />
    
</mcu>

 

czarusGG has reacted to this post.
czarusGG

SUCCESS!

Works in both versions of SimulIDE 🙂

Thank you very much!

Now, you need to remember to add the entry to the MCU definition 🙂

Thank you very much for your help.

arcachofo has reacted to this post.
arcachofo
Quote from arcachofo on December 14, 2023, 12:07 pm

Hi.

Seems that RAMPZ register is missing from atmega1284.

Please try this and let me know if the program is working:
Edit file data/AVR/mega1284 and add this at line 7:

    <regblock  name="I/O_REG" start="0x003B" end="0x003B" offset="32">
      <register  name="RAMPZ" addr="0x003B" bits="" />
    </regblock>
XML

 

The file should look like this:

<!DOCTYPE SimulIDE>

<mcu name="mega1284" core="AVR" data="16640" prog="131072" progword="2" eeprom="4096" inst_cycle="1" freq="16000000" >

    <include file="avr/avr_gpr.xml" />
    <include file="megaxx4/mxx4_regs.xml" />
    <regblock  name="I/O_REG" start="0x003B" end="0x003B" offset="32">
      <register  name="RAMPZ" addr="0x003B" bits="" />
    </regblock>
    
    <datablock name="RAM" start="0x0100" end="0x40FF"/>

    <include file="megaxx4/mxx4_int.xml" />
    <include file="megaxx4/mxx4_perif.xml" />
    
</mcu>
XML

 

I have the same issue, but in regular ATmega128. It happens when i try to do one of these operations in C:

PORTC = displays[display_pos]; // tabela[displays[display_pos]];
if i use display_pos, it works. if i try to use it as an index of displays (array of 4 unsigned chars) and also that result as an index of table (an arraty of 12 unsigned chars). In the simulator, it just shows as 0, so all segments light up (im using PORTC as inputs for 7seg displays)

I have the same issue, but in regular ATmega128. It happens when i try to do one of these operations in C:

Thanks for reporting.
The solution is the same but in file: data/AVR/mega128.mcu

average_simulide_enjoyer has reacted to this post.
average_simulide_enjoyer