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

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

Re: [avr-gcc-list] Bootloader question


From: Eric Pasquier
Subject: Re: [avr-gcc-list] Bootloader question
Date: Fri, 14 Dec 2007 14:19:30 +0100

Scott,

You wrote:
<<I have narrowed down the code to about 10 lines in a timer overflow interrupt, when I comment it out it works fine.>>

Is it the same as  "if ((mod3 % 40) == -1)" ?


May be you should post a piece of code.

Eric.



----- Original Message ----- From: "Scott Morken" <address@hidden>
To: <address@hidden>
Sent: Friday, December 14, 2007 12:12 PM
Subject: Re: [avr-gcc-list] Bootloader question


Hi

I compiled my (apparently) troublesome interrupt code as follows It should never run, this should hopefully eliminate any possibility of nested interrupts?

if ((mod3 % 40) == -1) //we are here 25x per second, for 25Hz sampling rate filter code
   {
       .....
    }

But my problem still appears, and I cannot enter the bootloader from my application, only if I reset the chip by toggling power.

This makes me suspect my problem is related to program size, but the numbers all look ok.

The chip I am using is an ATmega168 and the bootloader section starts at 0x3800. With my troublesome code not commented out my program size is 12674 (0x3182) and with it commented out (and working) the size is 12162 (0x2F82)

Scott

Eric Pasquier wrote:
Did you check that your treatment is not too long and that you do not have a problem with nested interrupt ?
How is your interrupt treatment ?
Is it possible to set the timer frequency differently to avoid the "mod3 % 40" test ?

Eric Pasquier


----- Original Message ----- From: "Scott Morken" <address@hidden>
To: <address@hidden>
Sent: Friday, December 14, 2007 9:26 AM
Subject: [avr-gcc-list] Bootloader question


Hi

I have an application that jumps to the bootloader using this function (it's a slightly modified avr109 bootloader made by atmel): void (*funcptr)( void ) = (void *)0x3800; // Set up function pointer to the bootloader start.

I call it when a command is sent over the serial port, making this code run:
UART_SendByte('B');
wdt_disable();//disable watchdog
cli();//disable all interrupts
for(counter = 0; counter<20000; counter ++)
{
   asm("NOP");
}
                      funcptr();//goto bootloader

It has been working great until some code was added to my application. Now it will not enter the bootloader properly when I send the command. I suspect the chip is crashing before it gets to the funcptr(); line. I have narrowed down the code to about 10 lines in a timer overflow interrupt, when I comment it out it works fine. Here are the suspect lines. All of the arrays are floats and the capital letter variables are integers:

if ((mod3 % 40) == 0) //we are here 25x per second, for 25Hz sampling rate filter code
   {

      //1st order, 7Hz -3dB lowpass, 25Hz sampling filter
       xv4[0] = xv4[1];
       xv4[1] = (float)GEN_V_DIV_ADC / 1.827271946;

       yv4[0] = yv4[1];
       yv4[1] = (xv4[0] + xv4[1]) + (-0.0945278312 * yv4[0]);

       GEN_V_DIV_ADC_FILTERED = yv4[1];




       //1st order, 3Hz -3dB lowpass, 25Hz sampling filter
       xv5[0] = xv5[1];
       xv5[1] = (float)SUPERCAP_DIV_ADC / 3.525711689;

       yv5[0] = yv5[1];
       yv5[1] = (xv5[0] + xv5[1]) + (0.4327386423 * yv5[0]);

       SUPERCAP_DIV_ADC_FILTERED = yv5[1];


   }

Does anyone know of a reason why it would crash?

Scott






_______________________________________________
AVR-GCC-list mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list




_______________________________________________
AVR-GCC-list mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list




_______________________________________________
AVR-GCC-list mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list






reply via email to

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