S. Assume The Bus Clock Is Running at 16 MHZ
S. Assume The Bus Clock Is Running at 16 MHZ
Question 6. Write a C function that uses SysTick to wait 100 s. Assume the bus clock is
running at 16 MHz.
Answer 1. SysTick is 24 bits.
Answer 2. SysTick counts down
Answer 3. SysTick counts at the bus clock frequency. In this class the bus clock is
initially 16 MHz and will change to 80 MHz once we activate the phase lock loop (PLL).
Answer 4. Reading NVIC_ST_CURRENT_R gets the current value of the counter.
Answer 5. When write any value to NVIC_ST_CURRENT_R it clears this register and
also clears the COUNT bit in the NVIC_ST_CTRL_R register.
Answer 6. (1599+1)*62.5ns = 100 s.
void SysTick_100usWait(void){
NVIC_ST_RELOAD_R = 1599; // number of counts to wait
NVIC_ST_CURRENT_R = 0; // any value written to CURRENT clears
while((NVIC_ST_CTRL_R&0x00010000)==0){ // wait for count flag
}
}