2024-03-18 02:28 AM - edited 2024-03-18 02:37 AM
I am running USB in Mass Storage host mode. On connecting the device, USB FLASH stick, it takes around 20 seconds to change the Appli_Sate from APPLICATION_START to APPLICATION_READY in usb_host.c file.
It is normal ? Can the time be reduced ?
Thanks
Solved! Go to Solution.
2024-03-19 05:00 PM - edited 2024-03-19 05:23 PM
Thanks @AScha.3
I had HAL_Delay(500) ; after MX_USB_HOST_Process(). I removed that and now state is changing in ms time...So the problem is solved.
Anyway how MX_USB_HOST_Process() works still confuses me. The whole USB connection process is blocking mode or interrupt mode still a mystery for me.
@AScha.3 May you please share part of code where you run swd + DWT counter..
2024-03-20 11:10 AM - edited 2024-03-20 11:11 AM
Jo,
first - in main:
volatile uint32_t *DWT_CONTROL = (uint32_t *)0xE0001000; // speed test: DWT addresses of registers
volatile uint32_t *DWT_CYCCNT = (uint32_t *)0xE0001004;
then, to use it:
*DWT_CYCCNT = 0; // clear counter
*DWT_CONTROL = *DWT_CONTROL | 1 ; // start cycle counter
...
...
count = *DWT_CYCCNT; // number of cycles stored in count variable
printf("%ld ns USB mounted \n", count * 5); // SWV ITM print
count * 5 = ns here, because core at 200MHz ; count is in cpu cycles, so adjust ...to get us or ns .
+
You have swd running ?
This is a bit tricky ...
to print you need just this, at end of main , i put before /*user...4*/ :
int __io_putchar(int ch)
{
ITM_SendChar(ch);
return (ch);
}
/* USER CODE END 4 */
Then set swo in debug settings and your cpu clk (otherwise - no work.)
Then start it in debug session, see :