2021-06-26 06:40 AM
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
}
2021-06-26 06:47 AM
Try doing this with a simple free-running TIM clocking at 1 MHz, 16-bit maximal mode
SysTick counts DOWN
Review what actual code is executing with the RCC/PLL settings.
Output the internal clock via MCO (PA8) and scope that.
2021-06-26 06:49 AM
For sub-microsecond granularity look at DWT CYCCNT, 32-bit up-count at core frequency
SysTick can clock at SYSCLK(HCLK,) or the SYSCLK DIV8, 24-bit down-count