Steward
分享是一種喜悅、更是一種幸福
微處理器 - Lattice GAL22V10 - C/C++ - Timer2
參考資訊:
https://www.stcmicro.com/datasheet/STC15F204EA-cn.pdf
https://www.stcmicro.com/datasheet/STC15F2K60S2-en.pdf
AUXR

Interrupt

IE2

main.c
#include <mcs51/8051.h>
__sfr __at(0x8E) AUXR;
__sfr __at(0xAF) IE2;
__sfr __at(0xD6) T2H;
__sfr __at(0xD7) T2L;
#define LED P1_2
void t2_isr(void) __interrupt 12
{
static int cnt = 0;
cnt += 1;
if (cnt > 255) {
cnt = 0;
LED ^= 1;
}
}
int main(void)
{
AUXR = 0x04;
T2H = 0x00;
T2L = 0x00;
IE2 = 0x04;
AUXR |= 0x10;
EA = 1;
LED = 1;
while (1) {
}
return 0;
}
完成
