Doest AVR-USB uses timers?

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
lpx
Posts: 7
Joined: Fri Apr 20, 2007 8:58 am

Doest AVR-USB uses timers?

Post by lpx » Mon Oct 27, 2008 8:41 pm

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

henni
Posts: 16
Joined: Mon Sep 08, 2008 4:17 pm

Re: Doest AVR-USB uses timers?

Post by henni » Thu Oct 30, 2008 4:04 pm

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!

Post Reply