Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Why my 89S uC can't Interrupt when interfce with Ds12887

Status
Not open for further replies.

hbaocr

Full Member level 4
Joined
May 13, 2007
Messages
232
Helped
25
Reputation
48
Reaction score
4
Trophy points
1,298
Location
Hochiminh City university of technology (VietNam)
Activity points
2,765
uC <-> Ds12887
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
}
 

It seems that the output of IRQ is drain open, it must connect a pullup resistor. In your code, you set IT1=1, thet means if P3^3 goes from High-to-Low will trigger interrupt.
So I think if IRQ is drain open, if has no interrupt, it is state is High Z, and use a pullup resistor, then output will be High. and When a interrupt comes, IRQ will become low, then P3^3 get the High-to-Low voltage, and will trigger uC interrupt.

Ryan
 

To fix your probem, I think you should follow this flow:

First, check when you give a negative clock voltage at P3^3, whether the uC will tirgger the interrupt. if the interrupt is OK, then do the second check. if NOT, check the interrupt register setting, insure the uC will accept and respons interrupt.

Second, check the IRQ of Ds12887, use oscillograph to see whether it has the Hight-to-Low change in the IRQ pin. if NOT, check your init setting of Ds12887.

Keeping on debugging, it will success! Good Luck!

Ryan
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top