obdev / v-usb

A Firmware-Only USB implementation for Atmel's AVR Microcontrollers
1.2k stars 241 forks source link

v-usb in CDC and timer issue. #13

Open hetii opened 7 years ago

hetii commented 7 years ago

Hello dear, I build small project that combine irmp and v-usb together. My project based on http://www.recursion.jp/prose/avrcdc/ and use latest v-usb drivers.

The point is int that when I run timer for irmp (15KHz) after a while of time I cannot send data to host by setting usbSetInterrupt(). uC is not freeze, I can still send data to it and for eg usbFunctionWriteOut() is called, but my data are not printed out anymore into terminal software(I use gtkterm or minicom under Linux).

What I notice when I restart just terminal software, communication back for a while and I got the last message that was buffered when usbSetInterrupt() was called.

In the attachment I put my complete code. The uart part can be even omitted, as I check the issue is related just to timer and its isr + usbSetInterrupt()

Maybe there is some way to flush the data or get back synchronization with host? Best Regards,

avr.tar.gz

lucasgcb commented 6 years ago

I know this is like a year old but I came across this library for my own projects to little success. All this failure is supported by the last paragraph of the project from nearly a decade ago you've linked, you'll realize the problem where it says:

The back door to the low-speed bulk transfer is gradually closing on the newer OS. After enjoying this USB technology, switch to the HID protocol or to MCU having on-chip USB controller.

V-USB is getting harder and harder to implement due to the fact it is tied to low-speed protocols. There's a reason OBDev doesn't really have this project on their front-page anymore. Even their marketing points are outdated and might as well be false advertising to some degree.

If you want to implement USB functionalities I'd recommend you try a dedicated chip (they are incredibly small and aren't even $1, even bundled with a board like Digispark's) with LUFA to program the firmware interface instead of using this fidgety thing.

In the case you're working with something like Arduino UNO for the USB serial programmer interface on the 328p, such a chip is already there and ready to go into Device Firmware Upgrade mode, making V-USB redundant.