Download Print this page

STC micro STC8A8K64D4 Series Reference Manual page 461

Advertisement

STC8A8K64D4 Series Manual
CMPCR2 = 0x10;
CMPCR1 = 0x00;
CMPCR1 &= ~0x02;
CMPCR1 |= 0x80;
while (1)
{
v = 0x00;
P1 = 0xfe;
delay();
if (!(CMPCR1 & 0x01)) goto ShowVol;
v = 0x01;
P1 = 0xfd;
delay();
if (!(CMPCR1 & 0x01)) goto ShowVol;
v = 0x03;
P1 = 0xfb;
delay();
if (!(CMPCR1 & 0x01)) goto ShowVol;
v = 0x07;
P1 = 0xf7;
delay();
if (!(CMPCR1 & 0x01)) goto ShowVol;
v = 0x0f;
P1 = 0xef;
delay();
if (!(CMPCR1 & 0x01)) goto ShowVol;
v = 0x1f;
P1 = 0xdf;
delay();
if (!(CMPCR1 & 0x01)) goto ShowVol;
v = 0x3f;
ShowVol:
P1 = 0xff;
P0 = ~v;
}
}
Assembly code
;Operating frequency for test is 11.0592MHz
CMPEXCFG
EQU
P_SW2
DATA
CMPCR1
DATA
CMPCR2
DATA
P0M1
DATA
P0M0
DATA
P1M1
DATA
P1M0
DATA
P2M0
DATA
P2M1
DATA
P2M1
DATA
P2M0
DATA
P3M1
DATA
P3M0
DATA
0FEFAH
0BAH
0E6H
0E7H
093H
094H
091H
092H
096H
095H
095H
096H
0B1H
0B2H
//Output comparator result after 16 debounce clocks
//Disable comparator output
//Enable comparator module
//Voltage <2.5V
//P1.0 outputs 0
//Voltage>2.5V
//P1.1 outputs 0
//Voltage>3.0V
//P1.2 outputs 0
//Voltage>3.5V
//P1.3 outputs 0
//Voltage>4.0V
//P1.4 outputs 0
//Voltage>4.5V
//P1.5 outputs 0
//Voltage>5.0V
- 445 -

Advertisement

loading
Need help?

Need help?

Do you have a question about the micro STC8A8K64D4 Series and is the answer not in the manual?

This manual is also suitable for:

Micro stc8a8k64d4-64pinMicro stc8a8k64d4-48pin