switch/case in boot code

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

The compiler (3.3) seems to put an 'lpm' instruction for the table jump in switch/case. This doesn't work very well in boot code (>64K).
Tell me I'm wrong and just forgot to flip some gcc switches.

Thanks for your attention

/B

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

Yes, I've done that already and it works fine.
However lengthy if-else-if do look messy compared to switch/cases.
I'll try to dig into the gcc docs for another solution.

BTW: my other posting about PSTR() is also related to this ugly addressing with
lpm/elpm:rampz.

I just started using your new 'boot.h', looks fine so far(fingers crossed).

Thanks

/B

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

FWIW, the switch/case statement does not work in the IAR compiler either.

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

Well I guess thats not a trivial problem, as the compiler doesn't have a clue where the code is placed. And the linker/locater doesn't have a clue aboat the actual code.

And still Atmel claims the AVR architecture was designed with C in mind.

What C? Vitamins?

That ugly RAMPZ bit to get the neccessary 17 bit address can't make any compiler writer really happy.

Nevertheless I anyhow still love the chip.

BTW: Is there anybody who knows if icc deals with this issue correctly?
icc has, if I remember correctly, some setup to put code in boot section.

Rgds
/B

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

Eric,

With boot.h it was a childs play.
I had more difficulties fiddling with the ihex file.
I simply cut-and-pasted your example into one function 'flashWritePage(addr, data)' and that was it.
My application is only 25K (so far), so I haven't yet tested >64K.

I run at 16MHz so my max serial speed is 57k6 (well 250k/500K/1M works too, but that's too fast for me) but anyhow the code loads faster than with my USBAVR programmer.

I see only happy faces.

Thanks again

/B