EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 578

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
- 562 -
{
int i;
for (i=0; i<100; i++);
}
void main()
{
P0M0 = 0x00;
P0M1 = 0x00;
P1M0 = 0x00;
P1M1 = 0x00;
P2M0 = 0x00;
P2M1 = 0x00;
P3M0 = 0x00;
P3M1 = 0x00;
P4M0 = 0x00;
P4M1 = 0x00;
P5M0 = 0x00;
P5M1 = 0x00;
ADC_CONTR = ADC_POWER | ADC_EPWMT | 0; // Select P1.0 as the ADC input channel
delay(); // Wait for the ADC power supply to stabilize
EADC = 1;
PWMSET = 0x01; //Enable PWM module (The configuration is effective only after
the module is enabled.)
P_SW2 = 0x80;
PWMCKS = 0x00; // The clock of PWM is the system clock
PWMC = 0x1000; // Set the period of PWM to 1000H PWM clocks
PWM0T1= 0x0100; // When the count value is 100H, the PWM0 channel outputs low level
PWM0T2= 0x0500; // When the count value is 500H, the PWM0 channel outputs high level
PWMTADC = 0x0200; // Set ADC trigger point
PWM0CR= 0x80; //Enable PWM0 output
P_SW2 = 0x00;
PWMCFG = 0x07; // Start the PWM module and enable the PWM interrupt and ADC trigger
EA = 1;
while (1);
}
void pwm0_isr() interrupt 22
{
if (PWMCFG & 0x08)
{
PWMCFG &= ~0x08;
}
}
void ADC_ISR() interrupt 5
{
ADC_CONTR &= ~ADC_FLAG;
}
Assembly code
;Operating frequency for test is 11.0592MHz

Table of Contents

Related product manuals