Help with USB_CDCD_ACM, sometimes garbage data, sometime correct data

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, i'm using samd21j16b. I tried using native usb functionality, with some progress, but i'm getting unestable results in communication.

If i do a loop where i send data to usb with 2sec delay, it works realtivley well with a a bit of grabage in between, but mostly well, if i run main program where i send a lot of data, i get mostly garbage and sometime what i send.

I like to debugg with 2 methods at the same time, atmel ice debugger and print to pc the data so i can see it in human language. most of the time i do this with uart and and external uart to usb converter, but this project requires to have usb functionalitty for configurations. I changed my debugging functions to send the datta via usb and as previously said, i get mostly garbage, and this won't work for my application.

So i'm thinking it could be a problem with some interrupts, that i would need to disable while usb communication is happening or with the usb clock.

Another problem i got, is that the function for sending float via usb send program to dummy_handler, in my experience this happens when you have a problem with memory allocation and as this function uses sprintf, i think the micro doesn't have enough memmory for it.

The problem occurs when its tries to do the sprintf command in that function. (i have sprintf on other functions and it works well).

I attached the project, any help would be apreciated :)

 

Attachment(s): 

This topic has a solution.
Last Edited: Wed. Jun 29, 2022 - 06:22 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your use of cdcdf_acm_write is not considering that it works asynchronously, there will be problems like overwrites and data on the stack that is not (no longer) available. 

Some code samples are here:

https://community.atmel.com/foru...