mini2440 timer study notes

Publisher:delta14Latest update time:2016-04-13 Source: eefocusKeywords:mini2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
    S3C2440 has 5 16-bit timers. Timers 0, 1, 2 and 3 have PWM functions (so these 4 timers are also called PWM timers), all have an output pin, and timer 4 is an internal timer without an external output pin. The
   clock source of the timer is PCLK, which is then divided by the internal two-stage divider to obtain the frequency required for the timer to work. Among them, timers 0 and 1 share an 8-bit first-stage prescaler prescaler 0, and timers 2, 3, and 4 share another 8-bit first-stage prescaler prescaler 1; each timer has a corresponding second-stage divider clock divider as shown in the figure below.

Although there are many timers, the working principles are the same. You only need to understand the working principle of one timer. For a certain timer, its internal structure schematic diagram is shown in Figure 2. The cache registers TCMPBn and TCNTBn are used to cache the comparison value and initial value of timer n; TCON is used to control the start and end of the timer; the current count value of the timer is obtained by reading the register TCNTOn.
 




                                    Overview of the working principle of the timer:
 ① First, load the comparison value and initial value of the timer into registers TCMPBn and TCMPBn
 ② Then, set the timer control register TCON and start the timer. At this time, the values ​​in TCMPBn and TCNTBn will be loaded into registers TCMPn and TCNTn.
 ③ At this time, the timer will count down by 1, that is, TCNTn will count down by 1. When TCMPn=TCNTn, the output of the TOUTn pin is opposite.
 
                                         Timer initialization①
 Timer clock frequency (for example, if the timer clock frequency is 50, then the 1-second count register will be subtracted by 50; if it is 100, then the 1-second count register will be subtracted by 100);
 ② Set the timer count value (for example, if the initial count value is 100 and the timer clock frequency is 50, an interrupt will occur after two seconds, such as the pin outputting the opposite level);
 ③ Set the interrupt processing function①
 
 
 
   Clock frequency initialization: Timer clock frequency = PCLK/(prescaler+1)/(divider value)
Among them: prescaler value = 0~255 (its value is set by the TCFG0 register, as shown in the figure below)
      divider value = 2,4,8,16 (its value is set by the TCFG1 register, as shown in the figure below)
 
TCFG0 Bit describe Initial Value
reserve [31:24]   0x00
Dead zone length [23:16] These 8 bits determine the length of the dead zone. The unit time of the dead zone length is equal to the unit time of timer 0.

 
0x00
Prescaler 1 [15:8] These 8 bits determine the pre-scaler value of timer 2, 3, and 4. 0x00
Prescaler 0 [7:0] These 8 bits determine the pre-scaler value of timer 0 and 1. 0x00

 
mini2440 timer study notes
 
 
     ② Count value initialization: These two registers store the set count comparison values, which can be directly assigned. The following takes timer 0 as an example:
    TCMPB0 Bit describe Initial Value
Timer 0 computer buffer register [15:0] Set compare buffer value for Timer0 0x00000000
 
 
   TCNTB0 Bit describe Initial Value
Timer 0 count buffer register [15:0] Set count buffer value for Timer 0 0x00000000
 
    ③ Set the interrupt processing function and write it yourself.
 
Example 1: Combined with the above explanation, we can know that the input clock of timer 0 is obtained by dividing the PCLK. The figure below shows its generation process. -------------------------------------Dividing line--------------------------------------------------- Analysis: In the previous question, two timer configuration registers TCFG1 and TCFG0 appear. Among them, the TCFG0 configuration register controls the division coefficient of the first-level divider prescaler, and the TCFG1 configuration register controls the multi-way selection switch to select the division coefficient of the second-level divider divider. The details are shown in the following figure: -----------------------------------------Dividing line----------------------------------------------------- -----------------------------------------Dividing line--------------------------------------------------- Example 2: PCLK is 50MHz, please set an appropriate division coefficient to make the input clock of timer 0 62.5kHz. Answer: Knowing that PCLK is 50MHz, 50MHz/62.5kHz=800, that is, PCLK needs to be divided by 800. Therefore, the frequency division coefficient of the first-stage frequency divider is 100, and the frequency division coefficient of the second stage is 8 to meet the requirements. Finally, you only need to write the frequency division coefficient to the corresponding bit in the timer control register. The code is as follows: 1  rTCFG0&=~(0xFF); clear the lower 8 bits of TCFG0 2  rTCFG0|=99; because the frequency division coefficient = prescaler+1, that is, prescaler+1=100, so prescaler value=99 3  rTCFG1&=~(0xF); clear the lower 4 bits of TCFG1
mini2440 timer study notes




 mini2440 timer study notes



mini2440 timer study notes

 
 


 
 
 
 rTCFG1|=0x02; Set the lower 4 bits of TCFG1 to 0x02, i.e. select 8-frequency output
Keywords:mini2440 Reference address:mini2440 timer study notes

Previous article:S3C2440 system clock
Next article:Parameter passing under ARM

Recommended ReadingLatest update time:2024-11-16 14:46

Linux-4.9.2 kernel porting on mini2440 (Part 2) Ubuntu compilation environment setup (Part 2)
2.1 Install arm-linux-compiler The compiler can be installed automatically in Ubuntu using the apt command, or it can be installed manually by downloading an independent installation package. Both installation methods can compile the kernel, and different versions of arm-linux-gcc can coexist in the system. This artic
[Microcontroller]
Linux-4.9.2 kernel porting on mini2440 (Part 2) Ubuntu compilation environment setup (Part 2)
Linux-2.6.32 transplanted SD card driver on mini2440 development board
Editor: This driver is quite complex, so let's port it first and analyze it later. SD card driver transplantation 1 Register SD device driver in the kernel Linux-2.6.32.2 already comes with the SD card driver for the S3C2440 chip. We only need to add the SD platform device structure to the initializati
[Microcontroller]
mini2440 i2c device support
Kernel version: linux-2.6.32.2 Experimental platform: mini2440 1. Add support for master devices The i2c master controller is also a device, but it is virtualized as a platform device in the kernel. The platform device has been defined in the kernel in plat-s3c/dev-i2c0.c: static struct resource s3c_i2c_resource = {
[Microcontroller]
STM32 Timer PWM_Output
The pulse width modulation mode can generate a signal with a frequency determined by the TIMx_ARR register and a duty cycle determined by the TIMx_CCRx register. The following is an example of PWM mode 1. The PWM signal reference OCxREF is high when TIMx_CNT   Library function STM32F10x_StdPeriph_Lib_V3.3.0\Proje
[Microcontroller]
STM32 Timer PWM_Output
MSP430F149 TIMER_A (I)——16-bit timing counter
    TIMER_A has four optional clock sources. For convenience, ACLK and SMCLK are generally selected. A time base is generated through a frequency divider. Its structure diagram is as follows:   TIMER_A has three timing/counting modes: (1). Incremental counting mode: Counting cycle: TAR increases from 0 to TAC
[Microcontroller]
u-boot2011.12 transplantation on mini24402
The error in the transplantation 1 of u-boot2011.12 on mini2440 was found after checking the source code that it was caused when NOR Flash support was started. Considering that NOR Flash support is not needed, NOR FLASH support is removed. 1. Add macro definition in mini2440.h #define CONFIG_SYS_NO_FLASH Used to tur
[Microcontroller]
PIC32MZ tutorial -- 32-bit Timer
  The microcontroller is PIC32MZ2048ECH144 on the PIC32MZ EC Starter Kit. This microcontroller has four 32-bit synchronous timers are available by combining Timer2 with Timer3, Timer4 with Timer5, Timer6 with Timer7, and Timer8 with Timer9. The 32-bit timers can operate in one of three modes: •Synchronous internal 3
[Microcontroller]
MINI2440 bare metal experiment: SDRAM
Programming This experiment will initialize SDRAM and copy the program itself to SDRAM and then jump to SDRAM to continue executing the pipeline. The modifications are still based on the last program. The files that need to be modified this time include "start.S" and "Makefile". The contents of the modified files are
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号