STC8A8K64D4 Series Manual
sbit
P_LED5
=
sbit
P_LED4
=
sbit
P_LED3
=
sbit
P_LED2
=
sbit
P_LED1
=
sbit
P_LED0
=
u16 idata adc[TOUCH_CHANNEL];
u16 idata adc_prev[TOUCH_CHANNEL];
u16 idata TouchZero[TOUCH_CHANNEL];
u8 idata TouchZeroCnt[TOUCH_CHANNEL];
u8 cnt_250ms;
void delay_ms(u8 ms);
void ADC_init(void);
u16 Get_ADC10bitResult(u8 channel);
void AutoZero(void);
u8 check_adc(u8 index);
void ShowLED(void);
void main(void)
{
u8 i;
P0M0 = 0x00;
P0M1 = 0x00;
P1M0 = 0x00;
P1M1 = 0x00;
P2M0 = 0x00;
P2M1 = 0x00;
P3M0 = 0x00;
P3M1 = 0x00;
P4M0 = 0x00;
P4M1 = 0x00;
P5M0 = 0x00;
P5M1 = 0x00;
delay_ms(50);
ET0 = 0;
TR0 = 0;
AUXR |= 0x80;
AUXR2 |= 0x01;
TMOD = 0;
TH0 = (u8)(Timer0_Reload >> 8);
TL0 = (u8)Timer0_Reload;
TR0 = 1;
ADC_init();
delay_ms(50);
for (i=0; i<TOUCH_CHANNEL; i++)
{
adc_prev[i] = 1023;
TouchZero[i] = 1023;
TouchZeroCnt[i] = 0;
}
cnt_250ms = 0;
while (1)
{
delay_ms(50);
P2^5;
P2^4;
P2^3;
P2^2;
P2^1;
P2^0;
// Initialize the 0-point, the previous value and the 0-point auto-tracking count
//Current ADC value
//Previous ADC value
//ADC value of 0-point
//Automatic tracking count for 0-point
//Initialize Timer0 to output a 300KHz clock
//Timer0 set as 1T mode
//Enable clock output
//Timer0 set as Timer, 16 bits Auto Reload.
//ADC initialization
//Delay 50ms
//Process key once every 50ms
- 504 -
Need help?
Do you have a question about the micro STC8A8K64D4 Series and is the answer not in the manual?