just a while ago, someone suddenly asked me systick_handler (void) How does this timer interrupt handler function be defined? Based on past experience, I feel that there should be a function declaration in the bottom of the existence of something, but down with the program, has not found the corresponding definition or declaration, then exactly how systick_handler this function? Is it possible to make changes artificially? Give me the first feeling is, must be able to make changes, after all, just a function of the name, so I looked at LPC1114 data sheet, combined with some reference documents on the Internet, to figure out exactly what is going on.
then it's still very easy to find . Systick_handler () The position of this function, as shown in:
we will find that almost all of the interrupt function names have been written here, so we sometimes use some of the interrupts in the program, can be found in this place. So, if we want to change the name of an interrupt, then we just need to make the changes here, and then use our own defined interrupt name in the program, but the actual situation to consider the problem, if we modify the name of these interrupt function, then it will reduce the portability of our code, So basically we do not recommend you to make changes here.
Speaking of Timer interrupt processing function, then how to set the timer Systick it?
is the LPC1114 system tick timer Systick structure diagram. The system tick timer is located in the Cortex-m0 kernel, which means that there will be a timer for LPC1114 or any other board with CortexM0 as the core. Its main purpose is to provide 100HZ (i.e. 10ms) timing functions for the embedded operating system. The system timer has a total of four registers: this can be clearly understood from the data sheet:
SYST_CSR: System Timer Control and status register SYST_RVR: System timer Reload value Register SYST_CVR: System timer Current value Register syst_calib: System timer Calibration Register
In the four registers of the system timer, the Syst_calib is the calibration register, which is already configured before the factory, so we don't have to consider this register. Then we need to configure a total of 3 registers to complete our work module.
so let's take a closer analysis of the three registers we're going to operate on .(1)SYST_CSR Register
There are 4 bits used in the CSR register, BIT0 is used to open the timer, 1 is allowed, bit1 is used to control whether the interrupt is generated, the position is 1 to allow interrupt, bit2 is used to set the timer clock source, set to 1, timer clock Source is the main clock, Conversely, set to 0, the clock source of the timer is half of the main clock.
(2)syst_rvr Register
RVR register used to 0~23 bit, this value is the initial value of the timer countdown, after opening the timer, will be set from here the value countdown to 0, countdown to 0 after the countdown will start from this value.
(3)SYST_CVR Register
Current: Read this register to return the present value of the system timer, assign a value to this register, will make the timer 0, and clear the Countflag bit in the CTRL. CVR Register is also used to 0~23 bit, this is a status register, when the timer began to operate, this value in constant change, from the RVR register to get the initial value, the countdown to 0.
System timer function--systick_config () function
The system comes with the Systick function, provided by Cmsis, is located in the Core_cm0.h file, in use, can be called directly, the function has a parameter ticks, by the statement inside the function systick->load = (Ticks & Systick_load_reload_msk)-1; know that ticks is an overloaded value that represents the count of two interrupts. The load in the Systick_config () function is what we said before Rsr,val is Cvr,ctrl is the previous CSR, the above operation is the register corresponding bit of the process of setting. function, the control register of the bit0,bit1,bit2 are set 1, against the previous register correlation bit definition can be known, the clock is equal to the frequency, open the system timer interrupt, allow the timer to run.
just a while ago, someone suddenly asked me systick_handler (void) How does this timer interrupt handler function be defined? Based on past experience, I feel that there should be a function declaration at the bottom of something like the existence, but down with the program, has not found the corresponding definition or declaration, then exactlySystick_handler, how did this function come about? Is it possible to make changes artificially? Give me the first feeling is, must be able to make changes, after all, just a function of the name, so I looked at LPC1114 data sheet, combined with some reference documents on the Internet, to figure out exactly what is going on.
Thoughts on the implementation of Systick interrupt function Systick_handler