Hi,
I am using an MKS22FN256VFT to act as an adapter between CAN and USB CDC.
After receiving CAN data, I send it as a 13 byte packet (4 bytes for message ID, 1 for length, and 8 for data) over the CDC device (taken from the mapsks22_1_dev_cdc_vcom_bm example).
Most of the time this works great, however sometimes the received USB packet is gibberish. I am using a Saleae Logic Pro to view the CAN and USB data.
- When working, I can see in the USB data and in RealTerm that the 13 bytes are all correct. Looking at the USB traffic and the Data0/1 fields show the correct 13 bytes.
- However, when the USB data is gibberish, I see the correct CAN data being received but the RealTerm and Data0/1 fields both show the same but incorrect data. I even put a breakpoint inside "USB_DeviceKhciEndpointTransfer" looking for a correct length packet (13) with invalid data (one of the CAN bytes should always be the same), and this breakpoint is never hit.
For me this means that the data is being sent through the layers of the USB stack, but still getting corrupted somewhere before being sent out.
Any ideas??