Using the PWM output of Timer0 in S3C2440 to drive the buzzer

Publisher:书香门第Latest update time:2020-05-12 Source: eefocusKeywords:S3C2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

There are five 16-bit timers in S3C2440, timer0, timer1, timer2, timer3 and timer4. Among them, only timer4 is an internal timer without output pins. Therefore, only timers 0, 1, 2, and 3 have pulse width modulation (PWM) function. Timer 0 has a dead zone generator for high current devices. (Hereinafter, timer 0 is used as an example)


The PWM output of S3C2440 mainly uses the comparison register TCMPB0 (0x51000010).


When the timer is enabled, the timer count buffer register (TCNTBn) gets an initial value that is loaded into the down counter. The timer compare buffer register (TCMPBn) has an initial value that is loaded into the comparator for comparison with the down counter value.


Each timer has its own 16-bit down counter driven by the timer clock. When the down counter reaches zero, a timer interrupt request is generated to notify the CPU that the timer operation has been completed. When the timer counter reaches 0, the corresponding TCNTBn value is also loaded into the down counter to continue the next operation (auto-load). However, if the timer is stopped, for example by clearing the timer enable bit of TCONn in timer run mode, the value of TCNTBn is not loaded into the counter.


The value of TCMPBn is used for pulse width modulation. When the value of the down counter matches the value of the compare register in the timer control logic, the timer control logic changes the output level. Therefore, the compare register determines the on time of the PWM output.


With the above knowledge, we can know


When initializing the timer, the following registers need to be set (taking timer 0 as an example):


Timer output clock frequency = PCLK/(prescaler value + 1)/(divider value)


TCFG0 (0x51000000), such as: TCFG0 = 99; // prescaler value = "99"


TCFG1(0x51000004), such as: TCFG1=0x03;//divider value="1/16"


Thus, when PCLK=400M, the timer output frequency is 6.25M


Next, we need to set the initial value for the timer.


TCNTB0 (0x5100000c), for example, TCNTB0 = 62500; // load the initial value and interrupt once every 1s


TCMPB0 (0x51000010), for example, TCMPB0 = rTCNTB0>>1; // 50%


If PWM is not used, TCMPB0 can be left unset or set to 0.


Then you can start the timer, but you must manually load TCON=1<<1 for the first time;


After loading, change to automatic loading and start timer TCON=0x09;


Where TCON (0x51000008)


In order to drive the buzzer, the I/O port must be initialized.


The board I used was Friendly, and the buzzer was connected to GPB0.


Enable PWM by changing the last two bits of GPBCON (0x56000010)


void GPIO_init(void)

{

 rGPBCON &= ~3;

 rGPBCON |= 2;

}

Keywords:S3C2440 Reference address:Using the PWM output of Timer0 in S3C2440 to drive the buzzer

Previous article:Friendly Arm Mini2440NORflash bootloader programming details --- personally tested and available
Next article:A brief introduction to the FriendlyArm mini2440

Recommended ReadingLatest update time:2024-11-23 10:16

Ethercat Real-time Industrial Ethernet Based on S3C2440
1 Introduction Industrial Ethernet is increasingly used in industry due to its low cost, easy networking, high data transmission rate, strong resource sharing capability, and easy Internet connection . Ethercat technology is a real-time industrial Ethernet technology proposed by BECKHOFF of Germany. It is based
[Microcontroller]
Ethercat Real-time Industrial Ethernet Based on S3C2440
Basic use of s3c2440 serial port
How to write UART program? 1. Serial port initialization Step 1: Set the pin ① Set the pins for the serial port. GPH2, 3 for TX0, RX0 Clear the bit, then set ② Set TX0 and RX0 internal pull-up, that is, configure the GPHUP register step2: Set baud rate (UBRDIV0) — 115200 == PCLK = 50MHz = UBRDIV0 = 26 ① Set UCON0 - Se
[Microcontroller]
s3c2440 bare metal-memory controller (2. Connection of different bit width peripherals and CPU address bus)
Connection of devices with different bit widths Let's first take a look at how the peripheral ROM is connected to the CPU address bus in the 2440 chip manual. Connection between 8bit rom and CPU address line Connection between 8bit*2 rom and CPU address line Connection between 8bit*4 rom and CPU address line Con
[Microcontroller]
s3c2440 bare metal-memory controller (2. Connection of different bit width peripherals and CPU address bus)
04-S3C2440u-boot learning u-boot analysis (4) u-boot command implementation
Refer to "Wei Dongshan 1st Video" Lesson 09 Section 4 u-boot analysis u-boot command implementation.WMV 1 Parse command: if exists; while (*str) {   /* * Find separator, or string end * Allow simple escape of ';' by writing ";" */ for (inquotes = 0, sep = str; *sep; sep++) { if ((*sep==''') &&     (
[Microcontroller]
04-S3C2440u-boot learning u-boot analysis (4) u-boot command implementation
s3c2440 porting Linux kernel, porting Linux-3.4.2 kernel to S3C2440
1. BootLoader boot kernel process 1. Bootloader Work 1.1. Read the kernel into memory 1.2. Save the kernel startup parameters to the specified location, and parse the parameters at this location when the kernel starts 1.3. Start the kernel and pass in the machine ID 2. Kernel startup process The primary purpose of t
[Microcontroller]
Detailed explanation of Uboot transplantation on S3C2440 (Part 2)
1. Transplantation Environment Host: VMWare--Fedora 9 Development board: Mini2440--64MB Nand, Kernel: 2.6.30.4 Compiler: arm-linux-gcc-4.3.2.tgz u-boot:u-boot-2009.08.tar.bz2 2. Transplantation Steps 4) Prepare to enter the second stage of u-boot (add support for Nor Flash on our developm
[Microcontroller]
Detailed explanation of Uboot transplantation on S3C2440 (Part 2)
S3C2440-5.Usage of UART
1. Introduction to UART in S3C2440 UART (universal asynchronous receive transmitter) is used to send and receive serial data and communicate in full-duplex mode. The level standard used by UART is TTL/CMOS. A frame of data usually contains a start bit, data bit, check bit, and stop bit. Both parties of UART transmissi
[Microcontroller]
S3C2440-5.Usage of UART
ARM processor startup process——S3C2440, S3C6410, S5PV210
S3C2440 Support booting from norflash and nandflash. Nandflash does not participate in unified addressing. The CPU always fetches instructions from the address 0. In order to boot from nandflash, the S3C2440 chip first copies the first 4kB of nandflash to the SRAM in the chip called stepping stone when the CPU starts.
[Microcontroller]
Latest Microcontroller Articles
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号