I use a simple delay clock code. But whenever I use this code program won't start without entering debug mode in KEIL. I plug stlink out and reconnect but it wont work if I don't enter the debug mode. Is there any solution to this. If not then what else can I use to have 100 us delay. Thank you for reading
uint32_t startTick = DWT->CYCCNT, delayTicks = 100 * (SystemCoreClock/1000000); while (DWT->CYCCNT - startTick < delayTicks);
The alternative obviously would be to create a different free-running TIM, perhaps clocking at 1 MHz (1us) and use that to mark time via TIMx->CNT, where TIMx->ARR is maximal, ie 0xFFFF or 0xFFFFFFFF for 16-bit and 32-bit respectively.
Ok thanks. I will also try this method.