This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Issues with writing my own project that communicates with a computer over USB.

Hi,

I've been trying to combine the spi_slave and USB_CDC_ADM examples so that I can pipe data from a spi_master all the way to my host machine. In my cobbled together project, the SPI transactions are working, but the USB isn't being properly sensed by my machine. I keep seeing this in my device manager:

The USB_CDC_ADM example works just fine though.

Any ideas on what I'm messing up? Thank you!

  • I don't think using the buffer as a string is a good idea here. A char array can be a string if the end of the array has a NULL character '/0' which you don't have. 

    To copy from one array to another array you can use memcpy instead.

    What I can see is that your  rx buffer is only 4 bytes, I dont know how you can get "comes_from_spi_mastr" as in the log. 

    Please get familiar with debugging, try to put a break point and view the buffer to see what you have there. 

  • Yea, that gave me some other issues. Since I really only care about the bits, I've switched to calculating a 32 bit value from the rx_buff and outputting that. While this fixed some string related null character handling, I'm still outputting nothing over the LOG and the actual (expected) number over USB, so I wonder if there's an order of operations issue. I'll step through with the debugger.

    Thanks for your help!

Related