Re:Help with Delay
Use SysTick as a system clock. You can set it as a free running clock, and divide systick values by the clock frequency. Or you can set the SysTickPeriod to the number of clocks in 1 ms. Then a SysTick interrupt can increase a system millisecond clock variable and your delay_ms function waits for this variable to increase by the required number.
You can use a loop that wait for the sys tick value but then you must be more careful in handling wraparounds, and since this runs at processor clock speeds you cannot use exact matches to check when the timer period has expired.
Use the driver lib functions for SysTick:
SysTickPeriodSet(20000); /* Period for 1ms at 20MHz clock */ SysTickPeriodSet(0xFFFFFFFF); /* Period for free running systick */
SysTickEnable(); SysTickIntEnable();
The game example code for the 811 eval board has a SysTick based delay function.
Beware that there are some problems using the COUNTFLAG to signal a SysTick timer zero crossing. (Cortex-M3 errata 377490)
login or register to reply
|