Page 1 of 1

HIDKeys with mega168

Posted: Fri Feb 12, 2010 5:37 am
by RazorConcepts
Has anyone successfully used HIDKeys example with a mega168?

I copied the exact schematic, except of course with the mega168 instead of the mega8.

To fix compile errors, I changed TCCR0 to TCCR0B, and two instances of TIFR to TIFR0. That is all I changed, and now everything compiles perfectly.

However, the computer says the device can not be recognized.

Any ideas? Thanks.

Additionally, has anyone gotten V-USB software to work with AVR Studio 4? It is very picky, and therefore not able to use the included makefile, which may have something to do with my problems :D

Re: HIDKeys with mega168

Posted: Fri Feb 12, 2010 6:44 pm
by ulao
Yup, done many projects with 168's The biggest mistake is using the whole watt diodes.. You need to use the 1/2 watt with 168's

Re: HIDKeys with mega168

Posted: Fri Feb 12, 2010 9:01 pm
by Grendel
RazorConcepts wrote:Additionally, has anyone gotten V-USB software to work with AVR Studio 4? It is very picky, and therefore not able to use the included makefile, which may have something to do with my problems :D

Used AVRS4 many times w/ V-USB. Just set up the project from scratch and ignore the makefile.

Re: HIDKeys with mega168

Posted: Mon Feb 15, 2010 12:27 am
by RazorConcepts
I am using half-watt diodes (the standard kind), but why would 1 watt diodes not work?

Also, if anyone has a working AVR Studio Project for the mega168 of any kind, I would greatly appreciate if you zip it up and post it. Thanks!

Re: HIDKeys with mega168

Posted: Mon Feb 15, 2010 3:07 am
by ulao
IIRC the electrical specs for the I/O pins are different between the 8 and 88. If you use Z-diodes on D+/D-, they HAVE to be 3V6/<= 500mW.

If I take one of my atmega projects and put 1 watt's on there, it will not enumerate. However on the atmega8 it works just fine. The atmega 8 projects should run just fine. Ever single one does for me. In some case I needed to rename the registers to match the atmega168, but if that were the case it woudl not compile. So it its compiling your code is good unless you changed something.

If you still have troubles, Check out
Replacing ATmega8 by ATmega88 http://www.atmel.com/dyn/resources/prod ... oc2553.pdf
Migrating between ATmega48, ATmega88 and ATmega168 http://www.atmel.com/dyn/resources/prod ... oc2554.pdf
Migrating from ATmega48/88 and ATmega48P/88P to ATmega48PA/88PA http://www.atmel.com/dyn/resources/prod ... oc8196.pdf

I also had an old usbdrvasm.o cause issues for the 168's I had to re download the latest, but I'm guessing you have the latest code an examples?

one other thing I remember is pd2 has an int on it, so if you use that pin make sure its disabled. I dont think any of the examples have the int enabled though.

Re: HIDKeys with mega168

Posted: Wed Feb 24, 2010 5:30 am
by RazorConcepts
Alright, so I decided to start fresh with HID-mouse. I copied the contents of the library into the same folder as the main.c (to ease AVR studio in finding these files). I got everything to compile except for the F_CPU part. I added the following at the top of main.c:

Code: Select all

#define F_CPU 16000000UL


But I get a ../usbdrvasm.S:383:9: error: #error "USB_CFG_CLOCK_KHZ is not one of the supported non-crc-rates!" error.

Tracing this back, usbconfig.h converts F_CPU to USB_CFG_CLOCK_KHZ by dividing F_CPU by 1000. So, with a 16000000khz F_CPU, I should get a 16000KHZ USB_CFG_CLOCK, which is in range of the acceptible values - but for some reason, it thinks it is wrong. Any ideas?

Re: HIDKeys with mega168

Posted: Wed Feb 24, 2010 8:43 am
by Grendel
Remove the F_CPU definition from main.c, the definition needs to be global. One way of adding it: in AVRS, load your project then open the menu "Project", select "Configuration Options". In that dialog under "General" fill out the "Frequency:" field w/ 16000000 . Click Ok and recompile.

Re: HIDKeys with mega168

Posted: Sat Feb 27, 2010 1:31 am
by RazorConcepts
Thank you, it works properly. I have attached a zip file of the complete AVR studio 4 project if people would like it as a starting point.
ATmega168 (not P or PA version) at 16mhz using the 2 4148 diodes in series circuit.

http://www.4shared.com/file/230550081/5 ... se168.html

Re: HIDKeys with mega168

Posted: Thu Mar 25, 2010 2:16 am
by RazorConcepts
Finally got a PCB made :D
This is the zener version with blue LEDs instead of zeners.
Image

Re: HIDKeys with mega168

Posted: Sat Mar 27, 2010 8:43 pm
by Ilia
could you post a schematic please?
I have also been trying to get a ATMega 168 working with V USB

Thanks,

Ilia