Page 1 of 1
atmega88p
Posted: Wed Jul 01, 2009 11:35 pm
by santacruzbob
hello, does anyone know if there are any quirks to running vusb (or specifically the usbasp and/or usbasploader) on the mega88p? I have assembled a couple really simple boards with D+ on PD2/INT0 and D- on PD4 with 68 ohm resistors, 3.6v 500mW zeners, 1.5k pullup on D- and 1M pulldown on D+ (pretty standard setup) however they will not enumerate. I have another project using mega168 which I built for the usbtiny ir/lcd project (which works well on the board) that just refuses to work with vusb. it's got the same hardware setup as the mega88p boards with the exception of the 1.5k pullup goes to PD3 rather than 5v (I tried setting that up in the config but it didn't seem to pull the line up. I've also added code to make that pin output high but I think it's being cancelled elsewhere.. I even tried moving the resistor so it's a pullup to +5v, still no luck. I'm really not sure what I'm doing wrong. I've built a few different projects using usbtiny that all work but I can't get anything going with vusb. if anyone has some advice I'd love it. I have an oscilloscope and I can see the D+/D- lines wiggling when initially plugged in (or D- gets pulled up..) I've also captured some packets using wireshark and it seems to just time out rather than responding to any of the usb host requests. thanks -Bob
Re: atmega88p
Posted: Sun Jul 05, 2009 12:09 am
by santacruzbob
still struggling with this issue. I have uploaded my schematic to
http://bob.desinc.net/bob-usb.png I think it's correct. I have changed the following settings in usbconfig.h (using the usbasp firmware)
#define USB_CFG_IOPORTNAME D
/* This is the port where the USB bus is connected. When you configure it to
* "B", the registers PORTB, PINB and DDRB will be used.
*/
#define USB_CFG_DMINUS_BIT 4
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
* This may be any bit in the port.
*/
#define USB_CFG_DPLUS_BIT 2
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
* This may be any bit in the port. Please note that D+ must also be connected
* to interrupt pin INT0!
*/
I also have played with some changes to main.c as follows
int main(void) {
uchar i, j;
/* no pullups on USB and ISP pins */
PORTD = 0;
PORTB = 0;
/* all outputs except PD2 = INT0 */
DDRD = ~(1 << 2);
/* output SE0 for USB reset */
DDRB = ~0;
j = 0;
/* USB Reset by device only required on Watchdog Reset */
while (--j) {
i = 0;
/* delay >10ms for USB reset */
while (--i)
;
}
/* all USB and ISP pins inputs */
DDRB = 0;
DDRD = 0;
/* all inputs except PC0, PC1 */
DDRC = 0x0B;
PORTC = 0xfe;
/* init timer */
clockInit();
does anyone have some advice? thanks -Bob
Re: atmega88p
Posted: Sun Jul 05, 2009 10:33 am
by rinku
Its correct!
santacruzbob wrote: I have changed the following settings in usbconfig.h (using the usbasp firmware)
#define USB_CFG_IOPORTNAME D
/* This is the port where the USB bus is connected. When you configure it to
* "B", the registers PORTB, PINB and DDRB will be used.
*/
#define USB_CFG_DMINUS_BIT 4
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
* This may be any bit in the port.
*/
#define USB_CFG_DPLUS_BIT 2
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
* This may be any bit in the port. Please note that D+ must also be connected
* to interrupt pin INT0!
*/
The configuration is right! all you need to do is to follow the circuit diagram given in V-USB/circuits/with-zener.
santacruzbob wrote:I also have played with some changes to main.c as follows
int main(void) {
uchar i, j;
/* no pullups on USB and ISP pins */
PORTD = 0;
PORTB = 0;
/* all outputs except PD2 = INT0 */
DDRD = ~(1 << 2);
/* output SE0 for USB reset */
DDRB = ~0;
j = 0;
/* USB Reset by device only required on Watchdog Reset */
while (--j) {
i = 0;
/* delay >10ms for USB reset */
while (--i)
;
}
/* all USB and ISP pins inputs */
DDRB = 0;
DDRD = 0;
/* all inputs except PC0, PC1 */
DDRC = 0x0B;
PORTC = 0xfe;
/* init timer */
clockInit();
The 1.5k pull up resistor in D- is mandatory, by this the host knows there is a low-speed device is connected, see USB 1.0 specification from usb.org. You cannot alter it by internal pull up of AVR MCU.
About your previous post, you said that the 1.5k pull up resistor is connected to another pin, instead of Vcc, this is because one can attach and deattach the device form the usb bus without physically removing the device. Bellow is the description from usbconfig.h:
/* ----------------------- Optional Hardware Config ------------------------ */
/* #define USB_CFG_PULLUP_IOPORTNAME D */
/* If you connect the 1.5k pullup resistor from D- to a port pin instead of
* V+, you can connect and disconnect the device from firmware by calling
* the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h).
* This constant defines the port on which the pullup resistor is connected.
*/
/* #define USB_CFG_PULLUP_BIT 4 */
/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined
* above) where the 1.5k pullup resistor is connected. See description
* above for details.
*/
Re: atmega88p
Posted: Tue Jul 07, 2009 2:19 am
by santacruzbob
rinku,
I appreciate the response. I am using hardware exactly as shown in that schematic (1.5k pullup to +5v which applies about 3.0v on the D- line due to the zener diode.) I've quadruple checked my hardware and I've even built 3 different boards hoping for a miracle but I get nothing. I have an oscilloscope but I'm not really sure where to start debugging. any further advice would be great.
Re: atmega88p
Posted: Tue Jul 07, 2009 4:57 am
by rinku
Have you tried some example like "hid-mouse" given in the folder "V-USB/examples" ?
Have you checked your F_CPU configuration and corresponding Fuse bits?
What development platform are you using?
It should be no problem to use V-USB with ATmega88, I am using it for various purpose. I think first you should try one example project to see things working, then you can go along with your requirement. if you need the hid-mouse example project compiled and build for ATmega88 (I am using GCC with AVR Studio in windows ), then let me know.
Re: atmega88p
Posted: Tue Jul 07, 2009 10:03 pm
by santacruzbob
rinku, perhaps I should have you compile the code for me. I have tried the unmodified usb-hid code with recommended fuses and still only get..
[571473.549538] hub 2-0:1.0: unable to enumerate USB device on port 1
[571474.366206] hub 2-0:1.0: unable to enumerate USB device on port 1
[571475.182875] hub 2-0:1.0: unable to enumerate USB device on port 1
it's difficult for me to troubleshoot since it appears my device just doesn't respond at all.
Re: atmega88p
Posted: Wed Jul 08, 2009 7:53 am
by rinku
There are two more thing to check:
1. have you used an external 12 MHz crystal resonator on PB6 & PB7?
2. If you are using windows, have you tried to uninstall the "unknown device" and re-install it (by searching for new hardware) from the Device manager?
The hid-mouse compiled project files are here :
http://rapidshare.com/files/253283459/m ... t.rar.html Project Configuration:
F_CPU 12000000
External Full Swing Crysta Fuse configuration
Optimization level -0S
Circuit diagram:
External 12 MHz crystal on PB6 & PB7, and other circuits are same as -> V-USB/circuits/with-zener
Re: atmega88p
Posted: Wed Jul 08, 2009 8:41 am
by santacruzbob
rinku,
I guess I'm gonna have to take a look at my toolchain. that code you compiled worked great first try (well, it made the mouse move all over my screen
bob@bowser ~/Downloads/mousetest/default $ avr-gcc -v
Using built-in specs.
Target: avr
Configured with: /var/tmp/cross/avr/portage/cross-avr/gcc-4.3.3/work/gcc-4.3.3/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/avr/gcc-bin/4.3.3 --includedir=/usr/lib/gcc/avr/4.3.3/include --datadir=/usr/share/gcc-data/avr/4.3.3 --mandir=/usr/share/gcc-data/avr/4.3.3/man --infodir=/usr/share/gcc-data/avr/4.3.3/info --with-gxx-include-dir=/usr/lib/gcc/avr/4.3.3/include/g++-v4 --host=x86_64-pc-linux-gnu --target=avr --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-libmudflap --disable-libssp --disable-libgomp --enable-cld --disable-libgcj --enable-languages=c --enable-shared --disable-threads --disable-bootstrap --disable-libgomp --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.3.3 p1.0, pie-10.1.5'
Thread model: single
gcc version 4.3.3 (Gentoo 4.3.3 p1.0, pie-10.1.5)
[I] cross-avr/avr-libc [1]
Available versions: 1.6.2 (~)1.6.4 {crosscompile_opts_headers-only doc nls}
Installed versions: 1.6.4(17:21:14 03/21/09)(nls -crosscompile_opts_headers-only -doc)
Homepage:
http://www.nongnu.org/avr-libc/ Description: C library for Atmel AVR microcontrollers
[I] cross-avr/binutils [1]
Available versions: (avr) (~*)2.15 2.16.1-r3 (*)2.16.91.0.6 2.17 2.17-r1 (~)2.17-r2 2.18-r3 (~)2.18-r4 **2.18.50.0.9 (~)2.19 (~)2.19.1-r1 **2.19.51.0.8 **2.19.51.0.9 **2.19.51.0.10
{gold multislot multitarget nls test vanilla}
Installed versions: 2.19.1-r1(avr)(17:17:08 03/21/09)(nls -multislot -multitarget -test -vanilla)
Homepage:
http://sources.redhat.com/binutils/ Description: Tools necessary to build programs
I'm not sure if you're running *nix, but if you are can you tell me what versions of avr-gcc, avr-libc, and binutils you're using? thanks a lot! should save me a couple gray hairs