five 32-bit timers
Timers 0 and 1 include a PWM function
Each timer has its own 32-bit down-counter which is driven by the timer clock. The down-counter is initially loaded
from the Timer Count Buffer register (TCNTBn). When the down-counter reaches zero, the timer interrupt request
is generated to inform the CPU that the timer operation is completed. When the timer down-counter reaches zero,
the value of corresponding TCNTBn can be automatically reloaded into the down-counter to start the next cycle.
However, if the timer stops, for example, by clearing the timer enable bit of TCONn during the timer running mode,
the value of TCNTBn will not be reloaded into the counter.
1 Timer 0 related registers
1) TCON timer control register (related to timer0 [3:0], switch, manual update of initial value, automatic reload of initial value (
when TCNT0 is reduced to 0, it is automatically loaded from TCNTB0 to TCNT0) etc.)
2) TCNTB0 stores the initial value of timer0;
TCMPB0 stores the value to be compared by timer0 (the default is 0, then tcnt0 is compared with tcmp0)
3) TINT_CSTAT Interrupt Control And Status Register) There are two bits related to timer interrupt control and timer0, [0] bit Timer 0 Interrupt Enable.
[5] bit Timer 0 Interrupt Status Bit. Clears by writing '1' on this bit. (This bit needs to be cleared by writing 1 in ISR)
4) TCFG0 Timer Configuration Register 0 that configures thetwo 8-bit Prescaler and DeadZone Length
sets the division factor of each timer. The lower eight bits are related to timer0 and timer1.
5) VIC0INTENABLE interrupt enable control (32 bits correspond to 32 interrupt sources (note that it is VIC0 group, timer0 is at 23 bits)
2Timer0 related register settings
Because an auto-reload operation of the timer occurs when the down counter reaches to 0, a starting value of the
TCNTn has to be defined by the user at first. In this case, the starting value has to be loaded by the manual
update bit . Take the following steps to start a Timer;
1) Write the initial value into TCNTBn and TCMPBn.
2) Set the manual update bit of the corresponding timer.
(Recommended setting the inverter on/off bit (whether using inverter or not)) .
3) Set the start bit of the corresponding timer to start the timer and clear only manual update bit.
timer0 init function in main.c
void timer_init(void)
{
TINT_CSTAT |= 1<<0; //Open timer0 interrupt, allow timer0 interrupt to occur
VIC0INTENABLE |= 1<<23; //Open timer0 enable (equivalent to turning off mask)
TCFG0 = 0x42; //Set the frequency division factor
TCNTB0 = 0x1000; //Set the initial value
TCON |= 1<<1; //Open Manual Update (Update TCNTB0,TCMPB0) and update TCNTB after setting the initial value
TCON |= 1<<3; 、、//Auto Reload on Automatic reload on
TCON |= 1<<0; //timer0 open;
TCON &= ~(1<<1); 、//No longer Update TCNTB0,TCMPB0
} Handler
irq_handler
in start.s
;push rets to stack
stmfd sp!,{r0-r12,lr}
;handler
bl do_timer_irq //jump to related execution function
;pop stack to regs
ldmfd sp!, {r0-r12,lr}
subs pc, lr,#4
The following is similar to external interrupts.
When timer0 interrupt occurs, the program goes to the entry 0x18 of the IRQ exception vector table, where the program jumps to IRQ_handler(); in the interrupt service function (ISR), it is necessary to write 1 to clear 0 to the 5th bit of TCON at the beginning; for the next interrupt
Previous article:s3c6410 DMA implementation (entry level)
Next article:Implementation of external interrupts for s3c6410
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Three steps to govern hybrid multicloud environments
- Three steps to govern hybrid multicloud environments
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- [Xingkong Board Python Programming Learning Main Control Board] Python development environment experience - graphic code can be quickly started
- Method of measuring automobile throttle sensor signal with auto repair oscilloscope
- 【NXP Rapid IoT Review】+① NXP Rapid IoT unboxing test
- How to detect whether the switching power supply transformer is good or bad?
- How to enable TI 15.4-Stack to support 470M frequency band
- 【Development Kit for nRF52840】+ Review 5-thread trial
- How to determine whether the EN enable pin of the chip needs a series resistor?
- Xunwei 4418 development board Linux system TFTP transfer file
- Thermal Design of Semiconductor Components: Heat Transfer and Heat Dissipation Paths
- 【Qinheng Trial】Implementation of USB HID