not sure if 1 atmega is enough

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
matias

not sure if 1 atmega is enough

Post by matias » Tue May 06, 2008 4:56 am

Hi,
I'm working on my project in which I use a atmega32. It has to act as a web server, so it has the tcp/ip stack loaded and communicates with an IC via SPI for this.
On the other side, it has to communicate with another module using USB, so here is where I get to AVR USB. My main question is: do you think it is possible to implement this system with just 1 uC? maybe 1 atmega for implementing the bridge and another for the rest...
what i have read in this forum is that AVR USB takes a lot of CPU time, but
i don't have to send large amounts of data via USB, just commands like 'turn somenthing on/off' or 'gimme your status' about once in a second or even less.

I hope somone could help me out. Thanks

osso
Posts: 7
Joined: Thu May 08, 2008 12:14 am

Post by osso » Thu May 08, 2008 12:43 am

It looks like that You want not to connect atmel via usb to pc, but to some other hardware ??? It will not work, avrusb is made to connect to ( mainly ) PC, to act as a "slave", not as a "master". If You want to connect to PC, why not use the tcp/ip or other protocol on network ?

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

Post by christian » Thu May 08, 2008 11:04 am

If you really want a USB device (not a host), then this should be possible. You MUST make sure that interrupts are never disabled for longer than a couple of CPU instructions. This means that your SPI interrupt routine must re-enable all interrupts (sei instruction) before doing anything else, even before pushing most of the registers. If you have a problem with reentrance in this interrupt handler, you may have to explicitly disable the SPI interrupt while global interrupts are enabled.

Regarding CPU load: AVR-USB needs the CPU for every USB data packet received or transmitted. If there is no USB traffic, it does not need any CPU time. However, USB is a polling bus. If the host expects data from the device, it polls by sending request packets in regular intervals. This happens all the time for bulk endpoints. And it happens while you process usbFunctionSetup() or usbFunctionRead() for control transfers.

Post Reply