EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 332

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
- 316 -
#include "reg51.h"
#include "intrins.h"
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;
sfr AUXR = 0x8e;
void INT1_Isr() interrupt 2
{
P0 = TL1; //TL1 is the low byte of the measured value
P1 = TH1; //TH1 is the high byte of the measured value
}
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;
AUXR = 0x40; //1T mode
TMOD = 0x80; //Enable GATE, and enable timing when INT1 is 1
TL1 = 0x00;
TH1 = 0x00;
while (INT1); //Wait for INT1 to be low
TR1 = 1; //Start timer
IT1 = 1; //Enable INT1 falling edge interrupt
EX1 = 1;
EA = 1;
while (1);
}
Assembly code
;Operating frequency for test is 11.0592MHz
AUXR DATA 8EH

Table of Contents

Related product manuals