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: Parthasaradhi Nayani
Subject: Re: [avr-gcc-list] ICP on ATmega8 helpme please
Date: Sat, 24 Feb 2007 10:23:30 -0800 (PST)

Hello Ricardo,
You are making simple mistake in your code. For example you are equating TIMSK but not ORing with the data. This will essentially over write the earlier value.

For example
    TIMSK   =(1<<TICIE1);           
    TIMSK   = (1<<TOIE1);

will result in the bit TOIE1 only setting and TICIE1 resetting. Hope this helps.

Nayani

"Ricardo Albarracin B." <address@hidden> wrote:
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<<
TIFR = (1<
TIMSK =(1<
TIMSK = (1<
DDRB &=~(1<
TCCR1B &=~(1<
ov_counter1 = 0;
sei();
}

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

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 |
+------------------------+------------------------+



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


Never miss an email again!
Yahoo! Toolbar
alerts you the instant new Mail arrives. Check it out.
reply via email to

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