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

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

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


From: Ricardo Albarracin B.
Subject: [avr-gcc-list] ICP on ATmega8 helpme please
Date: Sat, 24 Feb 2007 00:28:11 -0300

Hi:

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

Initialization:
void icp_init( void ) {

        TCCR1B  = (1<<CS11) | (1<<CS10);        // Prescaler clk/64
        TIFR    = (1<<ICF1);
        TIMSK   =(1<<TICIE1);                   
        TIMSK   = (1<<TOIE1); 
        DDRB &=~(1<<PB0);               // Set PB0(ICP) as input 
        TCCR1B &=~(1<<ICES1);           // Setting to rising edge 
        ov_counter1 = 0; 
        sei(); 
}       

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 */
        
        }
}


Regard in advance
-- 
Atentamente.                    Electronica y Unix
+------------------------+------------------------+
| Ricardo Albarracin B.  |  address@hidden   |
+------------------------+------------------------+
|counter.li.org:#238.105 | Fono:(56-2) 3905536    |
+------------------------+ Fax: (56-2) 6882641    |
|emails:address@hidden       | Agustinas 1022  Of.510 |
|MSN:   address@hidden |   Santiago - CHILE     |
+------------------------+------------------------+





reply via email to

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