Question
I set the MCU STM32F103C8 to 72 MHz (8 MHz external oscillator). However, the function does not give exactly 1 ms of time, but a value approximately 4 times larger. Any suggestion?
void delay_ms ( unsigned int i ){
unsigned int temp;
SysTick-> LOAD = 9000 * i; // if subtle, the SysTick-> LOAd = 9 * i;
SysTick->CTRL = 0x01;
SysTick->VAL = 0;
do{
temp = SysTick-> CTRL; // read the current countdown value
}while ( ( temp & 0x01 ) && ( !( temp & ( 1 << 16 ) ) ) );
SysTick-> CTRL = 0x00; // Close counter
SysTick-> VAL = 0; // counter is cleared
}