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

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

Re: [avr-gcc-list] ICP on ATmega8 helpme please


From: Galen Seitz
Subject: Re: [avr-gcc-list] ICP on ATmega8 helpme please
Date: Sat, 24 Feb 2007 08:05:46 -0800
User-agent: Thunderbird 1.5.0.9 (X11/20061222)

Ricardo Albarracin B. wrote:
Hi:

I'have problem with the code: using the AVR-GCC 4.1.1 this code not
work.

...snip...
SIGNAL( SIG_INPUT_CAPTURE1 ) {
        if( !ICES1 ){
        //Read ICR1 first
        value_init  = ICR1;
        TCCR1B |=(1<<ICES1);      // Change to falling edge
        }
        if( ICES1 ){
        //Read ICR1 High byte
        value_end = ICR1;
        TCCR1B &=~(1<<ICES1);
        }

        icp_value = value_end - value_init;
}


void main (void) {

        icp_init();

        while(1){
        
        /* send icp_value to serial port */
        
        }
}

In what way does it not work?  Have you declared icp_value as
volatile?
http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_volatile

Is icp_value larger than 8 bits?  If so, you will need to block
interrupts or use some other method of ensuring that the interrupt routine doesn't change icp_value while main is reading
it.  This FAQ entry is somewhat applicable.
http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_16bitio

BTW, SIGNAL is deprecated in later versions of avr libc.
http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html

galen




reply via email to

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