Skip to main content
swapnil champaneria
Associate III
September 17, 2020
Question

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

  • September 17, 2020
  • 2 replies
  • 1297 views

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

This topic has been closed for replies.

2 replies

TDK
September 19, 2020

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
September 26, 2020

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.