EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Example Routines; Output Waveforms with Arbitrary Period and Arbitrary Duty

Default Icon
901 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
STC8A8K64D4 Series Manual
- 550 -
19.3 Example Routines
19.3.1 Output waveforms with arbitrary period and arbitrary duty
C language code
//Operating frequency for test is 11.0592MHz
#include "reg51.h"
#include "intrins.h"
sfr P_SW2 = 0xba;
sfr PWMSET = 0xF1;
sfr PWMCFG1 = 0xF6;
#define PWMC (*(unsigned int volatile xdata *)0xFF00)
#define PWMCH (*(unsigned char volatile xdata *)0xFF00)
#define PWMCL (*(unsigned char volatile xdata *)0xFF01)
#define PWMCKS (*(unsigned char volatile xdata *)0xFF02)
#define PWMTADC (*(unsigned int volatile xdata *)0xFF03)
#define PWMTADCH (*(unsigned char volatile xdata *)0xFF03)
#define PWMTADCL (*(unsigned char volatile xdata *)0xFF04)
#define PWMIF (*(unsigned char volatile xdata *)0xFF05)
#define PWMFDCR (*(unsigned char volatile xdata *)0xFF06)
#define PWM0T1 (*(unsigned int volatile xdata *)0xFF10)
#define PWM0T1H (*(unsigned char volatile xdata *)0xFF10)
#define PWM0T1L (*(unsigned char volatile xdata *)0xFF11)
#define PWM0T2H (*(unsigned char volatile xdata *)0xFF12)
#define PWM0T2 (*(unsigned int volatile xdata *)0xFF12)
#define PWM0T2L (*(unsigned char volatile xdata *)0xFF13)
#define PWM0CR (*(unsigned char volatile xdata *)0xFF14)
#define PWM0HLD (*(unsigned char volatile xdata *)0xFF15)
sfr P0M1 = 0x93;
sfr P0M0 = 0x94;
sfr P1M1 = 0x91;
sfr P1M0 = 0x92;
sfr P2M1 = 0x95;
sfr P2M0 = 0x96;
sfr P3M1 = 0xb1;
sfr P3M0 = 0xb2;
sfr P4M1 = 0xb3;
sfr P4M0 = 0xb4;
sfr P5M1 = 0xc9;
sfr P5M0 = 0xca;
void main()
{
P0M0 = 0x00;
P0M1 = 0x00;
P1M0 = 0x00;
P1M1 = 0x00;
P2M0 = 0x00;
P2M1 = 0x00;
P3M0 = 0x00;

Table of Contents

Related product manuals