Learn ARM easily: Play with buzzer

Publisher:人妙果华Latest update time:2019-08-10 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Today we are going to learn how to easily learn the ARM series and play with the buzzer, based on the Samsung S5PV210 development platform of the ARM cortex_a8 core.


So let's see how to learn to use pwm to control the buzzer?


1. Overall Architecture Diagram


Before we can solve the buzzer problem, we need to have a certain understanding of the relevant chapters of Samsung's GPIO introduction, mainly the timer.


2. Several tips for playing with timers


2.1 Check the schematic diagram of the buzzer connection on the development board


Schematic diagram of the buzzer



The corresponding schematic diagram of the core board


2.2 Select the xpwmTOUT1 function of the GPD0CON configuration register


GPD0.GPD0CON = ((~(0xf 0)) & GPD0CON) | (0x2 << 4); Select PWM output function


2.3 Configuration of pre-scaling and frequency division registers


Configure the prescaler value, TIMER.TCFG0 = (TIME.TCFG0 & (~0xff)) | 0xff;


The prescaler value is set to 255 + 1

Configure the frequency division value to 16:


TIMR.TCFG1 = (TIME.TCFG1 & (~0xf0)) | (0x4 << 4);


2.4 Set the register value of the buffer counter and the value of the buffer comparator


Working principle: The value of the counter is decremented by 1 every clock cycle. If the value is equal to the value of the comparator, a high-low level conversion is performed, and the counter continues to decrement by 1 until it reaches 0, then it flips to achieve a complete square wave cycle.


Set the count buffer register value

        TIME.TCNTB1 = XXX; Set the total cycle, one pwm

        Set the compare buffer register value

        TIME.TCMPB1 = XXX/2; Setting is duty cycle


2.5 Manually update the value in the buffer register to the counter


Steps to set up pwm:



According to the second step of 1.3.15, first set the manual update, then clear the manual update and start the timer


Manual update, update the value in the buffer to the counter, double buffer mechanism


TIME.TCON = TIME.TCON & (0x0e << 8); 0000 1110


Clear the manual update bit and start the timer. 0000 1101 0x0d


TIME.TCON = TIME.TCON & (0x0d << 8);

Reference address:Learn ARM easily: Play with buzzer

Previous article:Learn ARM series I2C bus easily
Next article:S5PC100 peripherals pulse width modulation timer

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号