avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-gcc-list] jump_to_null question


From: Eric Weddington
Subject: RE: [avr-gcc-list] jump_to_null question
Date: Thu, 24 May 2007 07:16:54 -0600

 

> -----Original Message-----
> From: 
> address@hidden 
> [mailto:address@hidden
> org] On Behalf Of Dr. Jan Menzel
> Sent: Thursday, May 24, 2007 6:40 AM
> To: address@hidden
> Subject: [avr-gcc-list] jump_to_null question
> 
> Hi all!
>       I'm currently working on a bootloader for Mega8 and 88 
> and found a 
> problem I do not yet understand. At the end of the bootloader the code
> has to jump to the main reset vector at address 0x0000. If I do the
> usual way
>       void (*jump_to_null)(void) = 0x0000;
> gcc 3.4.6 complies:
>       LDI     R30, 0x0102
>       LDI     R31, 0x0103
>       ICALL
> and everything works fine, as expected.
>       But if I try to be more specific and define
>       void (* const jump_to_main)(void) = 0x0000;
> gcc 3.4.6 complies
>       RCALL   PC-0x0009
> which unfortunately does not what I intended.
>       Could anyone please point me to my error in reasoning 
> or lack of 
> understanding? Many thanks!
> 

1. Why do you need to declare it const, when the first way works fine?
2. The best way to reset the AVR, is not by jumping to the reset vector.
When you do that, some of the registers may be left in a state that is not
the default. The best way to reset is to enable the watchdog timer on the
shortest time-out, go into an infinite loop, and let the watchdog reset the
AVR. Depending on which AVR you are using, you will have to turn off the
watchdog timer after reset, with code in the .init3 section, for example.

Eric 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]