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.
[SOLVED] Problems on ATMEGA32/16MHz
[SOLVED] Problems on ATMEGA32/16MHz
Last edited by mschumann on Fri Jun 05, 2009 8:08 pm, edited 1 time in total.
Re: Problems on ATMEGA32/16MHz
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.
Re: Problems on ATMEGA32/16MHz
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
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