A simple example
-
- Posts: 6
- Joined: Tue Apr 27, 2010 11:42 pm
A simple example
Here's what I am looking for: The simplest possible firmware that could be burned onto an atmega168 with a 16mhz, and still be recognized as a USB device when plugged into a computer. Preferably in the form of a makefile, a main.c, and the usbconfig.h file.
I've been trying for a while now, unsuccessfully, to get V-USB working. But when I think I have it all straight, neither my PC nor my Mac recognize it as a USB device (Windows gives me a "device has malfunctioned error).
It could be anything: Code, Configuration, or hardware... but I have no way to debug any of that except to flash some leds when I reach a certain part of my code : / For all I know, one of my components could be bad. If someone could provide the simplest example of a USB device with a 16mhz crystal that doesn't require anything but the base circuitry for the chip and USB, I could focus on the checking the hardware, confident that the firmware end should work.
I've been trying for a while now, unsuccessfully, to get V-USB working. But when I think I have it all straight, neither my PC nor my Mac recognize it as a USB device (Windows gives me a "device has malfunctioned error).
It could be anything: Code, Configuration, or hardware... but I have no way to debug any of that except to flash some leds when I reach a certain part of my code : / For all I know, one of my components could be bad. If someone could provide the simplest example of a USB device with a 16mhz crystal that doesn't require anything but the base circuitry for the chip and USB, I could focus on the checking the hardware, confident that the firmware end should work.
Re: A simple example
Well I know its not on the 168 chip but this should work on it.
http://forums.obdev.at/viewtopic.php?f=8&t=3931
http://forums.obdev.at/viewtopic.php?f=8&t=3931
-
- Posts: 6
- Joined: Tue Apr 27, 2010 11:42 pm
Re: A simple example
Yo know, I saw that example, but at the bottom he says there's an error with it. Now that I'm looking at it again, even that error would appear to prove that the USB initializes.
But I'm a little confused at one thing... why does he calibrate the internal oscillator from 16.5 down to 8.25? If I'm using a 16mhz crystal, do I have to do some funky timing thing to make it work that isn't included in that simple example?
But I'm a little confused at one thing... why does he calibrate the internal oscillator from 16.5 down to 8.25? If I'm using a 16mhz crystal, do I have to do some funky timing thing to make it work that isn't included in that simple example?
Re: A simple example
The latest version of v-usb supports 16mhz, all you should have to do is set the freq in your make.
Re: A simple example
I am wondering about your hardware setup, please tell us more about this. For example are you using the zener diode method, I would assume this as the mega's wont do that fcpu at under 4.5V. IME all enumeration errors with the stock examples have been down to either incorrect fuse settings or disfunctional electronics.
-
- Posts: 6
- Joined: Tue Apr 27, 2010 11:42 pm
Re: A simple example
My breadboard setup is almost identical (barring possible mistakes made) to the metaboard here: http://metalab.at/wiki/Metaboard. The only difference is I left out the 7805 and related components since they are only needed if you play to have another power source besides USB.
-
- Posts: 10
- Joined: Tue Oct 07, 2008 11:44 am
Re: A simple example
wireframewolf wrote:Yo know, I saw that example, but at the bottom he says there's an error with it. Now that I'm looking at it again, even that error would appear to prove that the USB initializes.
But I'm a little confused at one thing... why does he calibrate the internal oscillator from 16.5 down to 8.25? If I'm using a 16mhz crystal, do I have to do some funky timing thing to make it work that isn't included in that simple example?
Yes there's an error message, but as the device shows up with lsusb I'm sure it's working as it shall. I have another project (http://www.patrikhermansson.se/?q=node/419), which doesn't add much code but works lika a charm.
-
- Posts: 6
- Joined: Tue Apr 27, 2010 11:42 pm
Re: A simple example
Well I finally got it working. Rebuilt my circuit and used the HID-Mouse example that comes with V-USB, and it worked for some reason. Now my problem is when I try to turn the example from a mouse to a keyboard, it shows up under keyboard devices in Windows, but tells me 'this device cannot start'. However, maybe that issue is for another thread.