[SOLVED] Problems on ATMEGA32/16MHz

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
mschumann
Posts: 14
Joined: Thu Jan 29, 2009 8:01 pm

[SOLVED] Problems on ATMEGA32/16MHz

Post by mschumann » Tue Jun 02, 2009 10:37 pm

Hi,
I am still working on my HTPC controller using an ATMEGA32, Graphical LCD, IR decoding ans USB (HID-Device) along with decoding some switches and two rotary encoders. All works well except for the USB port crashing from time to time. A lot of experiments seem to indicate that usbPoll() is under some circumstances not called often enough. This seems to crash the usb stack. Most of the time only disconnecting and rebooting the controller helps. It still works but the USB connection is down.

What can I do to make this more stable? Ist there a way to avoid these crashes by using an other type of device or extending timeouts? I cannot guarantee that usbPoll is called at least once in 50 ms since some of the GLC routines and also rc5 decoding take a lot of cpu.

Thanks in advance,

Micha

UPDATES:
I recoded the rc5 to polling only, not using any other interrupt pins. USB wont work stable, if I have timer0 (or timer1/2) on 16MHz with prescaler 1024 and only very few code lines. If I leave the overflow of that timer empty, everythin ist fine. I need to go that high frequency since rc5 has pulse times of aprox. 1.8ms.
Last edited by mschumann on Fri Jun 05, 2009 8:08 pm, edited 1 time in total.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Re: Problems on ATMEGA32/16MHz

Post by christian » Fri Jun 05, 2009 5:42 pm

The problem is not usbPoll(), it's the time spent in other interrupts or while interrupts are disabled. Other interrupts must have a sei as their first instruction (or at least within the fist 5 or 10 instructions) so that USB interrupts are not delayed for longer than a couple of microseconds.

mschumann
Posts: 14
Joined: Thu Jan 29, 2009 8:01 pm

Re: Problems on ATMEGA32/16MHz

Post by mschumann » Fri Jun 05, 2009 8:08 pm

Thanks,
thats exactly what I found out after several nights testing. I now have the sei() directly at the beginning of the critical timer overflow interrupt 0 and it runs like clockwork.
Thanks for your reply!
micha

Post Reply