Hello, I have been trying to perform USB communication between my AT89C5131A chip and pyUSB, to transmit some data to the microcontroller. I haven't been able to find any library which will help me achieve this and as a result I've been trying to understand the USB configuration mentioned in http://www.keil.com/dd/docs/datashts/atmel/at89c5131_ds.pdf.
On running the command dev.set_configuration(), I receive an error and I suppose this indicates a mistake in my configuration till that point.
My hardware bootloader however successfully runs with the dfu-programmer.
I've set the clock frequency correctly and enabled USBEN and FEN as mentioned.
1. Where am I going wrong? 2. Are there any good libraries for doing USB communication with AT89C5131A? 3. Should I switch to an AVR uC instead and use the LUFA library?
Thank you!
Hey Tsuneo, I overcame the previous problem by using a PC having the full license. I successfully detected my device as a CDC device in pyusb. However, I'm a bit unsure about step 2. I added something like this to my main()
while(1) { if ( uart_usb_tx_ready() && uart_usb_test_hit() ) { char c = uart_usb_getchar(); uart_usb_putchar(c); } }
Is this the correct place to write this code? On running this with pyusb, I get the following :- (131 is the endpoint address)
>>> dev.write(131, msg, 1) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 870, in write intf, ep = self._ctx.setup_request(self, endpoint) File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 190, in setup_request self.managed_claim_interface(device, intf) File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 146, in managed_claim_interface self.backend.claim_interface(self.handle, i) File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 747, in claim_interface _check(self.lib.libusb_claim_interface(dev_handle.handle, intf)) File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 552, in _check raise USBError(_strerror(ret), ret, _libusb_errno[ret]) usb.core.USBError: [Errno 16] Resource busy >>>
Which is the correct place to put the code for step 2)? What are some good resources to learn the USB protocol from?
Thank you, Kalpesh