hbaocr
Full Member level 4
uC <-> Ds12887
P0<->AD0-7
INT1<->IRQ
................
I have tested it, and I found that i can't make uC interrupt.
P0<->AD0-7
INT1<->IRQ
................
I have tested it, and I found that i can't make uC interrupt.
Code:
#include "REG52.h"
#include "ABSACC.h"
//define some variable for RTC
#define RTC P2
#define RTC_RegA 0x000A
#define RTC_RegB 0x000B
#define RTC_RegC 0x000C
#define RTC_RegD 0x000D
#define RTC_RegSecond 0x0000
#define RTC_RegMinute 0x0002
#define RTC_RegHour 0x0004
#define RTC_RegDayofweek 0x0006
#define RTC_RegDayofmonth 0x0007
#define RTC_RegMonth 0x0008
#define RTC_RegYear 0x0009
sbit INT = P3^3;
//declare function
void SetRTC(void);
//main function
void main()
{
//set INT1
INT=1; //cong nhap
IE=0x84;//cho phep ngat ngoai 1
IT1=1;//ngat canh xuong
P2=0x0F;
SetRTC;
while(1)
{ ;
//P2=PBYTE[0];
}
}
//===========chuong trinh phuc vu ngat========================
//ngat ngoai 1
void RTC_READY(void) interrupt 2
{
unsigned char kt;
EX1=0;//cam ngat
P2=PBYTE[0];
kt=PBYTE[RTC_RegC];//xoa thanh ghi C
EX1=1;//cho phep ngat lai
}
//==========set RTC========================
void SetRTC(void)
{
unsigned char t;
// cac bit trong thnah ghi B
// SET PIE AIE UIE SQWE DM 24/12 DSE
PBYTE[RTC_RegB]= 0x80;//set=1 o che do update du lieu ta co the ghi vao cac thanh ghi
//thanh ghi A
//UIP DV2 DV1 DV0 RS3 RS2 RS1 RS0 = 10100000
//cap nhat lai cho RTC
PBYTE[RTC_RegSecond]=0; //cap nhat du lieu
PBYTE[RTC_RegMinute]=0;
PBYTE[RTC_RegHour]=0 ;
//ket thuc cap nhat
PBYTE[RTC_RegA]= 0xA0; //DV2 DV1 DV0 =010 OSC on
PBYTE[RTC_RegB]=0x12; //UIE=1 enable Interupt ended upate
//DM=0 data BCD mode, 24/12=1 24h
//set=0 automatic update data
t=PBYTE[RTC_RegC];//xoa regC
}