stc12c2052ad pwm program

Publisher:知识智慧Latest update time:2013-05-11 Source: 21ICKeywords:stc12c2052ad  pwm Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

#include

sfr CCON =0xD8; //PCA control register
sfr CMOD =0xD9;
sfr CL =0xe9;
sfr CH =0xF9;
sfr CCAP0L=0xea; sfr
CCAP1L=0xeb;
sfr CCAP0H=0xfa;
sfr CCAP1H=0xfb;
sfr CCAPM0=0xda;
sfr CCAPM1=0xdb;

sbit CR=0xde; //Bit addressing

void main(void)
{
  CMOD=0x02; //Use system clock, clock input source frequency fosc/2. PWM frequency=fosc/2/256
            /************************************
    7 6 5 4 3 2 1 0 
   CIDL - - - cps2 CPS1 CPS0 ECF
                        
            CIDL: When =0, the PCA counter continues to work in idle mode; when =1, the PCA counter stops working in idle mode.
            CPS2, CPS1, CPS0: PCA counting pulse selection. 010, the overflow of timer 0 can realize PWM output with adjustable frequency.
             ECF: When =1, the interrupt of the CF bit in the register CCON is enabled; when =0, this function is disabled.
   ***************************************/
  CL=0x00;
  CH=0x00;
  CCAP0L= 0xc0; //When CL is less than CCAP0L, the output is low; when greater than CCAP0L, the output is high.
  CCAP0H=0x7f; //When CL changes from ff to 00 and overflows, CCAP0H is loaded into CCAP0L to achieve interference-free update of PWM.
  CCAP1L=0xc0; //When CL is less than CCAP1L, the output is low; when it is greater than CCAP1L, the output is high.
  CCAP1H=0xc0; //When CL changes from ff to 00 and overflows, CCAP1H is loaded into CCAP1L to achieve interference-free update of PWM.
  CCAPM0=0X42; //Enable PWM mode, PWM0=1, ECOM0=1
  CCAPM1=0X42; //Enable PWM mode, PWM1=1, ECOM1=1
  CR=1; //Start PCA counter
  while(1) 
  {
    CCAP0H=RF4432_TxRxBuf[4]; //Change the duty cycle here
 CCAP1H=RF4432_TxRxBuf[5];
 CCAP2H=RF4432_TxRxBuf[6]/2.5;
  };
}

Keywords:stc12c2052ad  pwm Reference address:stc12c2052ad pwm program

Previous article:STC12C5410AD AD test LCD12864 display program
Next article:STC MCU learning remote control program

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

Design and implementation of PWM soft-switching DC-DC converter for on-board charger
For the on-board charging system, the design requirements of DC-DC converters are first pointed out, and the inherent deficiencies of traditional primary-side phase-shifted full-bridge DC-DC converters are analyzed. Then, the research progress of PWM soft-switching DC-DC converters in on-board chargers is detailed f
[Embedded]
Design and implementation of PWM soft-switching DC-DC converter for on-board charger
You must know the fatal flaw of LED lamps - surge voltage
All LED lamps have this fatal defect, and so far, no one has proposed a good solution. All those who work on LED power supplies or finished LED lamps avoid talking about this problem and pretend not to know it. However, in actual mass production, this problem is endless. Of course, there are more people who don't know
[Power Management]
PWM combined with resistor network to achieve 16-bit WAV voice playback
introduction PWM wave is composed of harmonics and DC. Harmonics are signals that need to be filtered out. That is, the modulated PWM signal can be converted into an analog signal through an analog low-pass filter. The filter can eliminate most of the high-frequency components, leaving only the DC. Figure 1 is a sch
[Microcontroller]
PWM combined with resistor network to achieve 16-bit WAV voice playback
Key points for designing PWM functions using AVR timer/counter
1. Key points of timer/counter PWM design  According to the characteristics of PWM, the following points should be noted when using the ATmega128 timer/counter to design output PWM:  1. First, the PWM frequency range to be output should be determined according to the actual situation. This frequency is related to the
[Microcontroller]
The basic principle of PWM control
This application note details Zero Dew Pulse-Width Modul (PWM) Control (ZDP). ZDP TM is an MPS proprietary, fixed frequency power supply control method that improves transient response over common fixed frequency control methods such as voltage mode control or peak current mode control. Introduction MPS's
[Embedded]
2. avr timer/counter 0 --TC0 -- fast PWM output
PWM: Pulse Width Modulation. In the figure, T is the pulse period, t is the high level time, and the ratio of t to T (t/T) is called the duty cycle. Pulse width modulation refers to adjusting the size of t, that is, changing the duty cycle of the pulse . The larger the duty cycle value, the higher the output voltage.
[Microcontroller]
STM8S103 tim1PWM output
This article takes STM8S103F3P6 programming as an example to introduce STM8S103F3P6 timer 1 output PWM. experiment platform Computer platform: Windows 7 64-bit flagship Compiler software: IAR Hardware platform: STM8S103F3P6 Experimental content 1. The system clock is initialized to internal 16M CLK_HSIPrescaler
[Microcontroller]
STM8S103 tim1PWM output
MAX8792 Pulse-Width Modulation (PWM) Controller
The MAX8792 pulse-width modulation (PWM) controller features high efficiency, excellent transient response, and extremely high DC output accuracy to convert high battery voltages into low-voltage bias supplies for the core or chipset/RAM inside a notebook computer. The output voltage is controlled b
[Analog Electronics]
MAX8792 Pulse-Width Modulation (PWM) Controller
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号