IJMP irregularities after reset?

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a bizarre bug which means that code stops working properly after a power down reset. [It always works fine just after programming.]

I have discovered that if I take out a section of code containing an IJMP and table, the bug goes away (at least with the code I am working on at the moment). Whether this is just a red herring or not I don't know yet.

Has anyone else has ever run into irregularities with using IJMP?

I could understand strange errors if I was using EIJMP and didn't properly init the EIND Register, but this reg is not even in the devices I am using.

I even checked to make sure the assembler was generating the correct hex for the IJMP instruction.

Code goes like this, and I've used it a lot before:

ldz JumpTable
(That's my assembler macro to load Z with the address of the table of rjmp instructions)

add ZL,OFFSET
adc ZH,ZERO
ijmp

Got me stumped at the moment.

:shock:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

how have you determined that it is the ijmp that is the problem, and not the code that is being jumped to? Have you verified that the OFFSET and ZERO registers contain appropriate values?

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Have you verified that the OFFSET and ZERO registers contain appropriate values?

Ahem, **embarrassed face**, it seems that the programmer must leave the AVR registers zeroed, but I checked and my OFFSET register was not initialised. So after a reset / power down or whatever if the OFFSET reg was not zero or something in the range of the table, the code crashed.

I suppose I assumed the AVR regs were zeroed on reset like all the other I/Os and so on, but it seems not...