cancel
Showing results for 
Search instead for 
Did you mean: 

In USB CDC mode " hcdc->TxState = 0" not set to 1 after a few bunches of data transmitted on USB.

swapnil champaneria
Associate III

In my project i am print my log using printf function and in syscalls.c file i am print my printf log using CDC_Transmit_FS function.

__attribute__((weak)) int _write(int file, char *ptr, int len) {

CDC_Transmit_FS((uint8_t*) ptr, len);

return len;

}

after a sending some bunches of data CDC_Transmit_FS function return me USBD_BUSY error and not print data on my serial terminal.

Thanks and Regards

swapnil

2 REPLIES 2
TDK
Guru

Using something like this can run into issues if you're calling printf within an interrupt. CDC_Transmit_FS is unlikely to be re-entrant or thread safe, ensure you're only calling it from a single source, or disable interrupts around the call. Record the return value to ensure the function is successful.

If you feel a post has answered your question, please click "Accept as Solution".
swapnil champaneria
Associate III

Hello TDK,

thanks for replay, but In my case my all external interrupts are already set on priority level 1. and usb interrupt is set to 0 which is by default

and the problem is sometimes i didn't get interrupt from USB so my  hcdc->TxState = 0 not set to 1.