EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Using Comparator (Polling Mode)

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
- 439 -
ORL CMPCR1,#30H ; Enable edge interrupt of comparator
; ANL CMPCR1,#NOT 20H ; Disable comparator rising edge interrupt
; ORL CMPCR1,#20H ; Enable comparator rising edge interrupt
; ANL CMPCR1,#NOT 10H ; Disable comparator falling edge interrupt
; ORL CMPCR1,#10H ; Enable comparator falling edge interrupt
ANL CMPCR1,#NOT 08H ;P3.7 is CMP+ input pin
; ORL CMPCR1,#08H ;ADC is CMP+ input pin
; ANL CMPCR1,#NOT 04H ;internal 1.19Vreferrence voltage is CMP- input pin
ORL CMPCR1,#04H ;P3.6 is CMP- input pin
; ANL CMPCR1,#NOT 02H ; Disable comparator output
ORL CMPCR1,#02H ; Enable Comparator output
ORL CMPCR1,#80H ; Enable comparator module
SETB EA
JMP $
END
15.4.2 Using Comparator (Polling Mode)
C language code
// Operating frequency for test is 11.0592MHz
#include "reg51.h"
#include "intrins.h"
#define CMPEXCFG (*(unsigned char volatile xdata *)0xfeae)
sfr P_SW2 = 0xba;
sfr CMPCR1 = 0xe6;
sfr CMPCR2 = 0xe7;
sfr P1M1 = 0x91;
sfr P1M0 = 0x92;
sfr P0M1 = 0x93;
sfr P0M0 = 0x94;
sfr P2M1 = 0x95;
sfr P2M0 = 0x96;
sfr P3M1 = 0xb1;
sfr P3M0 = 0xb2;
sfr P4M1 = 0xb3;
sfr P4M0 = 0xb4;
sfr P5M1 = 0xc9;
sfr P5M0 = 0xca;
sbit P10 = P1^0;
sbit P11 = P1^1;
void main()
{
P0M0 = 0x00;
P0M1 = 0x00;
P1M0 = 0x00;
P1M1 = 0x00;

Table of Contents

Related product manuals