USB communication problems with ATmega8 (4nes4snes-adapter)
Posted: Wed Aug 03, 2011 11:41 pm
Hi,
I am new to microcontrollers and USB programming and I encountered a problem on my first project. I was rebuilding the 4nes4snes adapter from http://www.raphnet.net/electronique/4nes4snes/index_en.php and everything went fine until I connected the board with the USB port on my PC. As there was no communication at all with the ATmega8-16PU I used, I read through the Troubleshoot section on this webpage.
First I verified the fuse-bytes on the MC with avrdude which were fine (high: 0xC9 and low: 0x9F) as described on the homepage. I went through the code and found that F_CPU was set to 12000000 as it should be because I use a 12 MHz external crystal oscillator. I recompiled the source code on my own computer and flashed it again (and verified it), but it didnt change anything. Aftwards I added 104pF capacitors to D- and D+ which actually lets the computer communicate with the device but as it seems, it cannot decide on what speed it has to communicate with the 4nes4snes adapter. I also checked the wiring but it should be correct. So I think this might be a software problem and as said I tried compiling the source on my computer and the hex file from the homepage with the same result.
I use an ATmega8-16PU and the host is a Gentoo Linux 2.6.39-gentoo-r2. libusb does not list the device.
Output from dmesg after plugging the adapter in:
The message are repeated until i unplug the adapter. As Im not familiar with USB debug messages it seems as the computer cant figure out if its a USB 2 or USB 1 device as it switches between 480 and 1.5 Mb/s.
As my USB-cable comes from an older keyboard and has no shielding, I tried shortening it to 20cm but without luck. I dont know how this error can be resolved but maybe one of you here has encountered similar problems and can help.
Thanks
Gizmoomzig
I am new to microcontrollers and USB programming and I encountered a problem on my first project. I was rebuilding the 4nes4snes adapter from http://www.raphnet.net/electronique/4nes4snes/index_en.php and everything went fine until I connected the board with the USB port on my PC. As there was no communication at all with the ATmega8-16PU I used, I read through the Troubleshoot section on this webpage.
First I verified the fuse-bytes on the MC with avrdude which were fine (high: 0xC9 and low: 0x9F) as described on the homepage. I went through the code and found that F_CPU was set to 12000000 as it should be because I use a 12 MHz external crystal oscillator. I recompiled the source code on my own computer and flashed it again (and verified it), but it didnt change anything. Aftwards I added 104pF capacitors to D- and D+ which actually lets the computer communicate with the device but as it seems, it cannot decide on what speed it has to communicate with the 4nes4snes adapter. I also checked the wiring but it should be correct. So I think this might be a software problem and as said I tried compiling the source on my computer and the hex file from the homepage with the same result.
I use an ATmega8-16PU and the host is a Gentoo Linux 2.6.39-gentoo-r2. libusb does not list the device.
Output from dmesg after plugging the adapter in:
Code: Select all
[38018.859056] hub 6-0:1.0: hub_suspend
[38018.859075] usb usb6: bus auto-suspend
[38018.859081] usb usb6: suspend_rh
[46177.884928] hub 2-0:1.0: state 7 ports 6 chg 0000 evt 0004
[46177.884954] ehci_hcd 0000:00:1d.7: GetStatus port:2 status 001403 0 ACK POWER sig=k CSC CONNECT
[46177.884972] hub 2-0:1.0: port 2, status 0501, change 0001, 480 Mb/s
[46177.988119] hub 2-0:1.0: debounce: port 2: total 100ms stable 100ms status 0x501
[46177.988140] ehci_hcd 0000:00:1d.7: port 2 low speed --> companion
[46177.988178] usb usb6: usb wakeup-resume
[46177.988188] usb usb6: usb auto-resume
[46177.988193] usb usb6: wakeup_rh
[46178.020111] hub 6-0:1.0: hub_resume
[46178.020144] uhci_hcd 0000:00:1d.0: port 2 portsc 01a3,00
[46178.020152] hub 6-0:1.0: port 2: status 0301 change 0001
[46178.039126] ehci_hcd 0000:00:1d.7: GetStatus port:2 status 003002 0 ACK POWER OWNER sig=se0 CSC
[46178.039164] hub 2-0:1.0: state 7 ports 6 chg 0000 evt 0004
[46178.121154] hub 6-0:1.0: state 7 ports 2 chg 0004 evt 0000
[46178.121177] hub 6-0:1.0: port 2, status 0301, change 0000, 1.5 Mb/s
[46178.172256] hub 6-0:1.0: unable to enumerate USB device on port 2
[46178.172401] hub 2-0:1.0: state 7 ports 6 chg 0000 evt 0004
[46178.172421] ehci_hcd 0000:00:1d.7: GetStatus port:2 status 001403 0 ACK POWER sig=k CSC CONNECT
[46178.172438] hub 2-0:1.0: port 2, status 0501, change 0001, 480 Mb/s
[46178.276127] hub 2-0:1.0: debounce: port 2: total 100ms stable 100ms status 0x501
[46178.276145] ehci_hcd 0000:00:1d.7: port 2 low speed --> companion
[46178.327130] ehci_hcd 0000:00:1d.7: GetStatus port:2 status 003002 0 ACK POWER OWNER sig=se0 CSC
[46178.327166] hub 2-0:1.0: state 7 ports 6 chg 0000 evt 0004
[46178.454170] hub 6-0:1.0: state 7 ports 2 chg 0000 evt 0004
[46178.454188] uhci_hcd 0000:00:1d.0: port 2 portsc 01a3,00
[46178.454205] hub 6-0:1.0: port 2, status 0301, change 0001, 1.5 Mb/s
[46178.558140] hub 6-0:1.0: debounce: port 2: total 100ms stable 100ms status 0x301
[46178.609162] hub 6-0:1.0: unable to enumerate USB device on port 2
[46178.704101] hub 6-0:1.0: state 7 ports 2 chg 0000 evt 0004
[46178.704122] uhci_hcd 0000:00:1d.0: port 2 portsc 01a3,00
[46178.704139] hub 6-0:1.0: port 2, status 0301, change 0001, 1.5 Mb/s
[46178.808160] hub 6-0:1.0: debounce: port 2: total 100ms stable 100ms status 0x301
[46178.859201] hub 6-0:1.0: unable to enumerate USB device on port 2
[46178.859351] hub 2-0:1.0: state 7 ports 6 chg 0000 evt 0004
[46178.859374] ehci_hcd 0000:00:1d.7: GetStatus port:2 status 001403 0 ACK POWER sig=k CSC CONNECT
[46178.859392] hub 2-0:1.0: port 2, status 0501, change 0001, 480 Mb/s
[46178.963119] hub 2-0:1.0: debounce: port 2: total 100ms stable 100ms status 0x501
[46178.963137] ehci_hcd 0000:00:1d.7: port 2 low speed --> companion
[46179.014133] ehci_hcd 0000:00:1d.7: GetStatus port:2 status 003002 0 ACK POWER OWNER sig=se0 CSC
[46179.014170] hub 2-0:1.0: state 7 ports 6 chg 0000 evt 0004
[46179.204167] hub 6-0:1.0: state 7 ports 2 chg 0000 evt 0004
[46179.204184] uhci_hcd 0000:00:1d.0: port 2 portsc 01a3,00
[46179.204200] hub 6-0:1.0: port 2, status 0301, change 0001, 1.5 Mb/s
[46179.308064] hub 6-0:1.0: debounce: port 2: total 100ms stable 100ms status 0x301
[46179.359177] hub 6-0:1.0: unable to enumerate USB device on port 2
[46179.359319] hub 2-0:1.0: state 7 ports 6 chg 0000 evt 0004
[46179.359337] ehci_hcd 0000:00:1d.7: GetStatus port:2 status 001403 0 ACK POWER sig=k CSC CONNECT
[46179.359353] hub 2-0:1.0: port 2, status 0501, change 0001, 480 Mb/s
[46179.463153] hub 2-0:1.0: debounce: port 2: total 100ms stable 100ms status 0x501
[46179.463170] ehci_hcd 0000:00:1d.7: port 2 low speed --> companion
[46179.514172] ehci_hcd 0000:00:1d.7: GetStatus port:2 status 003002 0 ACK POWER OWNER sig=se0 CSC
[46179.514208] hub 2-0:1.0: state 7 ports 6 chg 0000 evt 0004
[46179.704078] hub 6-0:1.0: state 7 ports 2 chg 0000 evt 0004
[46179.704100] uhci_hcd 0000:00:1d.0: port 2 portsc 01a3,00
[46179.704117] hub 6-0:1.0: port 2, status 0301, change 0001, 1.5 Mb/s
[46179.808176] hub 6-0:1.0: debounce: port 2: total 100ms stable 100ms status 0x301
[46179.859201] hub 6-0:1.0: unable to enumerate USB device on port 2
[46179.954162] hub 6-0:1.0: state 7 ports 2 chg 0000 evt 0004
[46179.954183] uhci_hcd 0000:00:1d.0: port 2 portsc 01a3,00
[46179.954199] hub 6-0:1.0: port 2, status 0301, change 0001, 1.5 Mb/s
[46180.058118] hub 6-0:1.0: debounce: port 2: total 100ms stable 100ms status 0x301
[46180.109172] hub 6-0:1.0: unable to enumerate USB device on port 2
[46180.109356] hub 2-0:1.0: state 7 ports 6 chg 0000 evt 0004
[46180.109376] ehci_hcd 0000:00:1d.7: GetStatus port:2 status 001403 0 ACK POWER sig=k CSC CONNECT
[46180.109393] hub 2-0:1.0: port 2, status 0501, change 0001, 480 Mb/s
[46180.213117] hub 2-0:1.0: debounce: port 2: total 100ms stable 100ms status 0x501
[46180.213135] ehci_hcd 0000:00:1d.7: port 2 low speed --> companion
[46180.264133] ehci_hcd 0000:00:1d.7: GetStatus port:2 status 003002 0 ACK POWER OWNER sig=se0 CSC
[46180.264170] hub 2-0:1.0: state 7 ports 6 chg 0000 evt 0004
[46180.454071] hub 6-0:1.0: state 7 ports 2 chg 0000 evt 0004
[46180.454088] uhci_hcd 0000:00:1d.0: port 2 portsc 01a3,00
[46180.454104] hub 6-0:1.0: port 2, status 0301, change 0001, 1.5 Mb/s
[46180.558134] hub 6-0:1.0: debounce: port 2: total 100ms stable 100ms status 0x301
[46180.609166] hub 6-0:1.0: unable to enumerate USB device on port 2
[46180.609349] hub 2-0:1.0: state 7 ports 6 chg 0000 evt 0004
[46180.609367] ehci_hcd 0000:00:1d.7: GetStatus port:2 status 001403 0 ACK POWER sig=k CSC CONNECT
[46180.609384] hub 2-0:1.0: port 2, status 0501, change 0001, 480 Mb/s
The message are repeated until i unplug the adapter. As Im not familiar with USB debug messages it seems as the computer cant figure out if its a USB 2 or USB 1 device as it switches between 480 and 1.5 Mb/s.
As my USB-cable comes from an older keyboard and has no shielding, I tried shortening it to 20cm but without luck. I dont know how this error can be resolved but maybe one of you here has encountered similar problems and can help.
Thanks
Gizmoomzig