Page 1 of 1

Doest AVR-USB uses timers?

Posted: Mon Oct 27, 2008 8:41 pm
by lpx
Hi,

I want to use AVR-USB but i also want to make use of a 16-bit timer.

When using the 16-bit timer the avr usb stops working and vice versa.

Is there any problem using a 16 bit timer togheter with AVR USB?

This is my timer code:

ISR(TIMER1_OVF_vect)
{
PORTC=~PORTC; //Invert the Value of PORTC

timeCounter += 100;
}


void initTimer() {

// Output Compare Register A = 18750
OCR1A = 18750;

// Mode of operation: CTC, Prescaler = FCPU/64
TCCR1B |= (1<<WGM12) | (1<<WGM12) | (1<<CS11) | (1<<CS10);
TIMSK1 |= (1<<OCIE1A);

//Initialize Counter
TCNT1=0;

//Port C[3,2,1,0] as out put
DDRC=0xFF;

PORTC=~PORTC; //Invert the Value of PORTC

}

Thanks,

Nuno

Re: Doest AVR-USB uses timers?

Posted: Thu Oct 30, 2008 4:04 pm
by henni
No.
Exception: When you use the 12.8 MHz module and synchronize dynamically (very new firmware), Timer0 (8bit) is used.

lpx wrote:I want to use AVR-USB but i also want to make use of a 16-bit timer.
When using the 16-bit timer the avr usb stops working and vice versa.

This has nothing to do with timers (or any other built-in peripheral hardware) but with interrupt load.
lpx wrote:ISR(TIMER1_OVF_vect)
{
PORTC=~PORTC; //Invert the Value of PORTC
timeCounter += 100;
}

Is USB not connected to PortC?
Does this ISR work fast enough (it looks like)?

lpx wrote:OCR1A = 18750;

You put a quite large integer to an 8-bit I/O register!