2022-07-05 02:42 AM
Hello. I'm currently implementing USB Drag and Drop Bitstream loader for FPGA using STM32F103CBTB and latest CubeIDE (1.10.0). The implementation uses STM32 in USB Mass storage class and virtual file system based on FAT12. The part of Drag and drop is working fine. But If I add 200ms delay into the code (line 354) which is under STORAGE_Write_FS() in usbd_storage_if.c , This cause USB to halt. So, my question is there any way to pause USB transaction for 200ms delay and continue transaction? I attached the source of usbd_storage_if.c down below for who want to take a look at. Thank in advance!
Solved! Go to Solution.
2022-07-10 07:13 PM
I solved the problem. I was able to add delay by using while loop decrement.
uint32_t cnt = 0x1FFFF; // This seems to give me ~200ms delay at 48MHz clock
STORAGE_Write_FS(){
// Stuffs before delay
while(cnt--); // the delay
// Stuffs after delay
}
One thing I discovered is the code optimization affect this delay. By set to non or optimize for debug doesn't break the delay. But other optimization break the delay.
2022-07-05 04:43 AM
2022-07-05 05:54 AM
Thanks for the reply. It's quite similar to my code but the answer still not so clear. I might try something else.
2022-07-10 07:13 PM
I solved the problem. I was able to add delay by using while loop decrement.
uint32_t cnt = 0x1FFFF; // This seems to give me ~200ms delay at 48MHz clock
STORAGE_Write_FS(){
// Stuffs before delay
while(cnt--); // the delay
// Stuffs after delay
}
One thing I discovered is the code optimization affect this delay. By set to non or optimize for debug doesn't break the delay. But other optimization break the delay.