EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 573

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
- 557 -
#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 PWM0_Isr() interrupt 22
{
static bit dir = 1;
static int val = 0;
if (PWMCFG & 0x08)
{
PWMCFG &= ~0x08; //Clear interrupt flag
if (dir)
{
val++;
if (val >= CYCLE) dir = 0;
}
else
{
val--;
if (val <= 1) dir = 1;
}
_push_(P_SW2);
P_SW2 |= 0x80;
PWM0T2 = val;
_pop_(P_SW2);
}
}
void main()
{
P0M0 = 0x00;
P0M1 = 0x00;
P1M0 = 0x00;
P1M1 = 0x00;
P2M0 = 0x00;
P2M1 = 0x00;
P3M0 = 0x00;
P3M1 = 0x00;
P4M0 = 0x00;
P4M1 = 0x00;

Table of Contents

Related product manuals