Hello all AVR freaks,
First of all, congratulations on LUFA! Great job!!
So, I am working in a project at my university which I have to read the signal from a sensor that uses SENT protocol (Single Edge Nibble Transmission). This means that I have to measure the time between the falling edges of the sensor's output square wave. And of course: I have to send the time measured to the pc right after every measurement (before the next falling edge).
I installed the LUFA extension for Studio 6.2 and am using the "USB to Serial converter" example. It works almost perfect, except for one problem. The data I have to send is between 3 and 4 bytes. If the USB 2.0 has a speed of 12Mbit/s, it means that every bit takes ~83ns (and I measured it to confirm). 4bytes = 32bits = 2656ns. My first question is: how many and which are the other bytes of every message? I would say it is not only my data in the message, or?
My second question would be: the time between the falling edges that I have to measure can vary from 10 to 900 microseconds"¦ from 900 to 100 microseconds, everything works perfect. I get the complete data at the terminal (1byte: msg number and 3 other bytes with data). But when I start to decrease the time, like to 80 or 50 microseconds, then some messages are lost and even repeated"¦ The more I decrease, the worse it gets.
I would like to know if I can send messages faster than the 100 microseconds that I am getting now, and what I have to change in the project to accomplish that.
One thing I was concerned was about the CDC_Device_USBTask(&VirtualSerial_CDC_Interface); and USB_USBTask(); in the main loop. I am actually not using USB task anymore, just the CDC device task. But what I did was to use a second timer to count ~24ms, and then it would call this task. I thought calling the CDC device task every time in the main loop was slowing it down, but it actually didn't make that much difference. I have already tried changing other stuff too, but no success so far"¦
I hope you guys can help me!
Thank you very much and hope to hear from you soon!