2021-04-09 04:24 AM
Hello everyone and i hope youre having a great embedded morning.
CDC_Transmit_FS() bricks itself when i check status of the ongoing transmission
is there any mechanism to know when a CDC_Transmit_FS transaction is finished?
When i try to CDC_Transmit_FS before the previous CDC_Transmit_FS is done retval=USBD_BUSY which is to be expected, well after that CDC_Transmit_FS doesnt work anymore always returning USBD_BUSY.
This code bricks the usb peripheral and can only be used again after system reset:
do {
//HAL_Delay(100);
retval=CDC_Transmit_FS(&buffer, receivedbytes);
} while (retval!=USBD_OK);//
retval=CDC_Transmit_FS("finished transmission", sizeof("finished transmission"));//this will return HAL_OK but no transaction will be done
If i place a dirty delay big enough for the first transaction to be done everything works.
retval=CDC_Transmit_FS(&buffer, receivedbytes);
HAL_Delay(1000);
retval=CDC_Transmit_FS("finished transmission", sizeof("finished transmission"));
im using STM32f205ret6
CubeMX Version 6.1.1
Solved! Go to Solution.
2021-04-28 01:39 AM
So i didnt find a solution after 2 weeks struggle...
What ive done is just transmitt data in smaller chunks of 4kB data and place small hal_delay(300); in between.
uint8_t aux=receivedbytesUSB/0x800;//how many full 4kb pages we want to transmitt
for(uint8_t i=0;i<aux;++i){ //transmitt full 4kb pages
CDC_Transmit_FS(&txBufferUSB68K[i*0x800], 0x800);
HAL_Delay(300);
}
//transmitt the last less than 4kb page
CDC_Transmit_FS(&rxBufferUSB68K[aux*0x800], receivedbytesUSB%(aux*0x800));
HAL_Delay(300);
This is not ideal but it works
2021-04-30 02:52 AM
Hello, I find myself in similar situation, my communication is blocked and stalls the whole microcontroller trying to transmit an irregular amount of data.
In your workaround, what value do you give to "receivedbytesUSB"?
Thank you
2021-05-02 11:22 PM
@LHUAN.1 received bytes is a variable ammount of data,
what my app does is:
I also realised very glitchy behaviours when trying to send buffers bigger than 4kB, thats why i send the txBufferUSB68K[] in 4kB chunks