skip to content
Alabourre.com
User Tools
Log In
Site Tools
Search
Tools
Show page
Old revisions
Backlinks
Recent Changes
Media Manager
Sitemap
Log In
>
Recent Changes
Media Manager
Sitemap
Trace:
public:tech:tm4c123g:systick
===== Initialization of SysTick ===== #define NVIC_ST_CTRL_R (*((volatile unsigned long *)0xE000E010)) #define NVIC_ST_RELOAD_R (*((volatile unsigned long *)0xE000E014)) #define NVIC_ST_CURRENT_R (*((volatile unsigned long *)0xE000E018)) void SysTick_Init(void){ NVIC_ST_CTRL_R = 0; // 1) disable SysTick during setup NVIC_ST_RELOAD_R = 0x00FFFFFF; // 2) maximum reload value NVIC_ST_CURRENT_R = 0; // 3) any write to current clears it NVIC_ST_CTRL_R = 0x00000005; // 4) enable SysTick with core clock } ===== Use of SysTick to measure elapsed time ===== unsigned long Now; // 24-bit time at this call (12.5ns) unsigned long Last; // 24-bit time at previous call (12.5ns) unsigned long Elapsed; // 24-bit time between calls (12.5ns) void Action(void){ // function under test Now = NVIC_ST_CURRENT_R; // what time is it now? Elapsed = (Last-Now)&0x00FFFFFF; // 24-bit difference Last = Now; // set up for next... } ===== Use of SysTick to delay for a specified amount of time (C10_SysTick_Wait) ===== #define NVIC_ST_CTRL_R (*((volatile unsigned long *)0xE000E010)) #define NVIC_ST_RELOAD_R (*((volatile unsigned long *)0xE000E014)) #define NVIC_ST_CURRENT_R (*((volatile unsigned long *)0xE000E018)) void SysTick_Init(void){ NVIC_ST_CTRL_R = 0; // disable SysTick during setup NVIC_ST_CTRL_R = 0x00000005; // enable SysTick with core clock } // The delay parameter is in units of the 80 MHz core clock. (12.5 ns) void SysTick_Wait(unsigned long delay){ NVIC_ST_RELOAD_R = delay-1; // 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 } } // 800000*12.5ns equals 10ms void SysTick_Wait10ms(unsigned long delay){ unsigned long i; for(i=0; i<delay; i++){ SysTick_Wait(800000); // wait 10ms } }
public/tech/tm4c123g/systick.txt
ยท Last modified: 2025/01/22 16:49 by
127.0.0.1
Page Tools
Show page
Old revisions
Backlinks
Back to top