STC12C5A60S2_PWM

Publisher:TranquilWhisperLatest update time:2019-06-01 Source: eefocusKeywords:STC12C5A60S2 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

#include

#include

#define uint unsigned int 

#define uchar unsigned char

sfr CCON = 0XD8;

sbit CCFO = CCON^0;

sbit CCF1 = CCON^1;

sbit CR = CCON^6;

sbit CF = CCON^7;

sfr CMOD = 0XD9;

sfr CL = 0XE9;

sfr CH = 0XF9;

sfr CCAPM0 = 0XDA;

sfr CCAP0L = 0XEA;

sfr CCAP0H = 0XFA;

sfr CCAMP1 = 0XDB;

sfr CCAP1L = 0XEB;

sfr CCAP1H = 0XFB;

sfr PCAPWM0 = 0XF2;

sfr PACPWM1 = 0XF3; //PWM related registers

 void PWM_Init() //PWM initialization function

 {

     CMOD = 0X02; //Set the working mode register  

     CL = 0X00; //low 8-bit counter cleared         

     CH = 0X00; // Clear the high 8-bit counter

     /*********Mode 0*************/

     CCAPM0 = 0X42; // Mode 0 pin works in 8-bit PWM without interruption. The CCON register can be used to set the interruption.

     PCAPWM0 = 0X00; //Set the upper 9 bits to 0

     CCAP0L = 0X00; //Set the initial value to 0

     CCAP0H = 0X00; //Set the initial value to 0

     /*********Mode 1**************/

     CCAMP1 = 0X42;

     PACPWM1 = 0X00;

     CCAP1H = 0X00;

     CCAP1L = 0X00; //same as above

     CR = 1; //Start PCA counter

}


void PWM_Set(uchar Mod0,uchar Mod1) //Set duty cycle

{

    CCAP0L = Mod0;

    CCAP0H = Mod0;

    CCAP1L = Mod1;

    CCAP1H = Mod1;

}

void main()

{

    PWM_Init();

    PWM_Set(0XF0,0XFF);

    while(1);

}




Keywords:STC12C5A60S2 Reference address:STC12C5A60S2_PWM

Previous article:51 Analog PWM
Next article:STC89C52RC MCU realizes serial port printing function

Recommended ReadingLatest update time:2024-11-16 19:35

STM32 learning notes: PWM output
1. PWM Introduction Pulse Width Modulation (PWM) is a very effective technique to control analog circuits using the digital output of a microprocessor, i.e. the control of pulse width. Except for TIM6 and 7, all other timers of STM32 can be used to generate PWM output. Among them, advanced timers TIM1 and TIM8 can gen
[Microcontroller]
Stm32 generates two PWMs with a phase difference of 180 degrees
Because the two complementary PWM signals with dead zones generated by the advanced timer last time cannot meet the application requirements. As the title indicates, two PWM signals with a phase difference of 180 degrees are required. The duty cycle and frequency are the same, but the phase is different. After careful
[Microcontroller]
Stm32 generates two PWMs with a phase difference of 180 degrees
STM32TIM module generates PWM
 This is the PWM output mode of STM32. The TIM1 module of STM32 is an enhanced timer module, which is born for motor control. It can generate 3 groups of 6 PWMs. At the same time, each group of 2 PWMs is complementary and can have a dead zone, which can be used to drive the H-bridge.   The following code is an example
[Microcontroller]
STM32F103_TIM3 outputs PWM wave to realize full-color breathing light
1. LED lights 1. Must be full-color RGB_LED light 2. 256 colors are mixed by different red, green and blue LEDs, which is the same as the color mixing RGB888 in computer drawing. Each light uses 8 bits to control its brightness, and all lights off represent black. two, 1. LED brightness level table /* LED br
[Microcontroller]
STM8 hardware PWM settings
I've been playing around with STM8 recently, learning and using it, and I found that there are many things I don't understand. I wrote this blog to record my experience of using PWM to control the speed of the motor in the past few days, and also to keep a technical archive for future use. 1. Initialize the timer
[Microcontroller]
Saizhuo Electronics launches the transmission speed sensor chip platform SC9685/86 with high cost performance + PWM protocol + vibration suppression + ASIL-B!
With the continuous growth of market demand and the arrival of opportunities for localization of chips, the market size of the speed sensor industry will continue to expand. Saizhuo Electronics launched the gearbox sensor chip SC9685/86, which is a PWM protocol Hall speed sensor platform used for transmission system
[Automotive Electronics]
Saizhuo Electronics launches the transmission speed sensor chip platform SC9685/86 with high cost performance + PWM protocol + vibration suppression + ASIL-B!
【51】PWM control use
PWM, which stands for Pulse Width Modulation, is the abbreviation of pulse width modulation. It modulates the width of a series of pulses to produce the required waveform (including shape and amplitude). By adjusting the duty cycle, the change of signal, energy, etc. can be adjusted. The duty cycle refers to the per
[Microcontroller]
【51】PWM control use
Design and Proteus simulation of multi-channel servo control PWM generator
Abstract: PWM pulse width signal modulation is a kind of pulse signal widely used in modern electronics industry, and its typical application is steering gear control. Based on Proteus and Keil software, this paper introduces the implementation method of using 51 single-chip microcomputer to generate multiple PWM pu
[Industrial Control]
Design and Proteus simulation of multi-channel servo control PWM generator
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号