【s3c2440】Lesson 5: Timer Interrupt

Publisher:RadiantDuskLatest update time:2022-07-21 Source: csdnKeywords:s3c2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Introduction to s3c2440 timer

OVERVIEW

  ~ 

         ~~~~~~~~        The S3C2440A has five 16-bit timers. Timer 0, 1, 2, and 3 have Pulse Width Modulation (PWM) function. Timer 4 has an internal timer only with no output pins. The timer 0 has a dead-zone generator, which is used with a large current device.

  ~ 

         ~~~~~~~~        The timer 0 and 1 share an 8-bit prescaler, while the timer 2, 3 and 4 share other 8-bit prescaler. Each timer has a clock divider, which generates 5 different divided signals (1/2, 1/4, 1/8, 1/16, and TCLK). Each timer block receives its own clock signals from the clock divider, which receives the clock from the corresponding 8-bit prescaler. The 8-bit prescaler is programmable and divides the PCLK according to the loading value, which is stored in TCFG0and TCFG1 registers.

  ~ 

         ~~~~~~~~        The timer count buffer register (TCNTBn) has an initial value which is loaded into the down-counter when the timer is enabled. The timer compare buffer register (TCMPBn) has an initial value which is loaded into the compare register to be compared with the down-counter value. This double buffering feature of TCNTBn and TCMPBn makes the timer generate a stable output when the frequency and duty ratio are changed.

  ~ 

         ~~~~~~~~        Each timer has its own 16-bit down counter, which is driven by the timer clock. When the down counter reaches zero, the timer interrupt request is generated to inform the CPU that the timer operation has been completed. When the timer counter reaches zero, the value of corresponding TCNTBn is automatically loaded into the down counter to continue the next operation. 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.

  ~ 

         ~~~~~~~~        The value of TCMPBn is used for pulse width modulation (PWM). The timer control logic changes the output level when the down-counter value matches the value of the compare register in the timer control


The above is excerpted from the s3c2440 chip manual. This paragraph introduces the configuration of the timer peripherals in the s3c2440. From it, we can know:


There are 5 timers TIM0 ~ TIM4, except TIM4, all of them have PWM function.


TIM0 and TIM1 use the same 8-bit prescaler to divide PCLK as their clock. TIM2 ~ TIM4 use the same 8-bit prescaler to divide PCLK as their clock. Each TIM has a divider.


The timer counter TCNTBn stores the initial value loaded into the subtraction counter TCNTn, and the s3c2440 timer counts down. The timer compare register TCMPBn stores the initial value loaded into the compare register TCMPn.


Each timer has a 16-bit down counter TCNTn. When the counter value is equal to 0, an interrupt is triggered, and then the value of TCNTBn is loaded into the down counter.


TCMPBn is used in PWM mode.


Steps to configure the timer

TIMER INITIALIZATION USING MANUAL UPDATE BIT AND INVERTER BIT

    ~~~   

         ~~~~~~~~        An auto reload operation of the timer occurs when the down counter reaches 0. So, a starting value of the TCNTn has to be defined by the user in advance. In this case, the starting value has to be loaded by the manual update bit. The following steps describe how to start a timer:


Write the initial value into TCNTBn and TCMPBn.

Set the manual update bit of the corresponding timer. It is recommended that you configure the inverter on/off bit. (Whether use inverter or not).

Set start bit of the corresponding timer to start the timer (and clear the manual update bit).

If the timer is stopped by force, the TCNTn retains the counter value and is not reloaded from TCNTBn. If a new value has to be set, perform manual update.


First initialize TCNTBn and TCMPBn.

Set the manual update bit, update TCNTn and TCMPn, and then reset the manual update bit.

Turn on auto-reload and timer.

Keywords:s3c2440 Reference address:【s3c2440】Lesson 5: Timer Interrupt

Previous article:【s3c2440】Lesson 4: External Interrupts
Next article:S3C2440 development board learning - how to burn bare board program

Recommended ReadingLatest update time:2024-11-15 16:28

17. S3C2440 bare metal—IIC interface
17.1 Introduction to IIC interface 17.1.1 Concept of IIC bus     The I2C bus is a simple, bidirectional two-wire synchronous serial bus developed by Philips . It requires only two wires to transfer information between devices connected to the bus.   The master device is used to start the bus to transmit data and gener
[Microcontroller]
17. S3C2440 bare metal—IIC interface
I2S Audio Bus Learning (Part 3) S3C2440 I2S Controller
In our own product test, the submachine runs normally in normal mode without any problems. However, if the remote host keeps sending data, the product LCD screen will be distorted and the serial port will freeze. Moreover, the two machines, the one that displayed the LCD screen distorted and then froze after the s
[Microcontroller]
I2S Audio Bus Learning (Part 3) S3C2440 I2S Controller
S3C2440 OpenJtag
C:UsersAdministratorDesktop oflash.exe leds.bin +---------------------------------------------------------+ |   Flash Programmer v1.5.4 for OpenJTAG of www.100ask.net  | |   OpenJTAG is a USB to JTAG & RS232 tool based FT2232   | |   This programmer supports both of S3C24X0 & S3C6410    | |   Author: Email/MSN(thisw
[Microcontroller]
Detailed Explanation of S3C2440 Memory Controller
The memory space of S3C2440 is divided into different blocks. When the CPU sends an address to the memory controller, the memory controller sends the corresponding chip select signal to the chip select pin according to the address range to realize the control of different devices. BANK0 BUS WIDTH
[Microcontroller]
Detailed Explanation of S3C2440 Memory Controller
u-boot2009.11 s3c2440 transplantation notes
After working hard for several days, U-BOOT finally has some features. Although nandflash is not ready yet, booting from nandflash is not currently supported. Let’s take a picture first haha.   As the current mainstream bootloader, u-boot is also divided into two parts: boot and loader. Boot: (the basic support funct
[Microcontroller]
Detailed explanation of S3c2440ARM exception and interrupt system 1---concept introduction and processing flow
Take a scene to explain the interruption. Suppose there is a large room with a small room inside, a baby is sleeping, and his mother is reading outside. Question: How can the mother know when the child wakes up? Open the door every once in a while to see if the baby is awake, and then continue reading. Wait unti
[Microcontroller]
Detailed explanation of S3c2440ARM exception and interrupt system 1---concept introduction and processing flow
S3C2440 nor_flash driver
Similar to the previous nandflash, let's re-learn the norflash driver here. 1 /* 2 * Refer to driversmtdmapsPhysmap.c 3 */ 4 5 #include linux/module.h 6 #include linux/types.h 7 #include linux/kernel.h 8 #include linux/init.h
[Microcontroller]
Some unclear concepts in S3C2440
UART Universal Asynchronous Receiver/Transmitter, UART is the abbreviation of Universal Asynchronous Receiver/Transmitter. UART is a chip used to control computers and serial devices. SPI interface SPI (Serial Peripheral Interface) bus system is a synchronous serial peripheral interface that enables MCU to communica
[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号