Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

Rtc 12887 programming problem

Status
Not open for further replies.

dinesh401

Advanced Member level 4
Joined
Aug 21, 2010
Messages
104
Helped
3
Reputation
4
Reaction score
2
Trophy points
1,298
Location
BANGALORE
Activity points
2,077
sir, i am trying to display time on a 7 segment display using ds12887 and at89s52 controller. I am using port 0 to interface ds 12887 and using four 7447 BCD to 7 seg decoder at port 1 and port 3. My hardware module was working correctly. When i am dumping my program with some initial values it was giving only the value. The time wasn't changing. Below is my program.
#include<reg51.h>
#include<absacc.h>

#define BYTE unsigned char
#define SECOND 0x22
#define MINUTES 0x41
#define HOURS 0x01
#define DAY 0X22
#define MONTH 0X05
#define YEAR 0X11
void main(void)
{
delay(200);
XBYTE[10]=0X20; //turn on osc.
XBYTE[11]=0X83; //BCD, 24hrs, daylight savings
XBYTE[0]=0X40; //SECOND=40H FOR BCD
XBYTE[2]=0X41; //MINUTE=40h for BCD
XBYTE[4]=0X01; //HOUR=01h for BCD
XBYTE[7]=0X22; //DAY=22H
XBYTE[8]=0X05; //month=05h
XBYTE[9]=0X11; //year=11h
XBYTE[11]=0X03; //allow update
}

This is my intialization program.

#include<reg51.h>
#include<absacc.h>

#define BYTE unsigned char
#define SECONDS 0x44
#define MINUTES 0x41
#define HOURS 0x01

char hr, min;

void delay(int time)
{
int i,j;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}

void main()
{
P1=0x00;
while(1)
{

hr=XBYTE[4];
P1=hr;

min=XBYTE[2];
P1=min;

}
}



This is my time program to display on 7 segmnt display.
Can you tel me the problem plzz
 

grieblm

Member level 4
Joined
May 7, 2011
Messages
75
Helped
18
Reputation
36
Reaction score
18
Trophy points
1,308
Location
Georgetown, Canada
Activity points
1,734
Why are you using two different programs? Shouldn't you be initializing and reading the clock in the same program?
 

dinesh401

Advanced Member level 4
Joined
Aug 21, 2010
Messages
104
Helped
3
Reputation
4
Reaction score
2
Trophy points
1,298
Location
BANGALORE
Activity points
2,077
thanks for your reply sir,
if i use both the programs in one single program,,i thought that the initalization block will again executed when we power on the ckt again. so the time will change when we power on it again..so i thought to initialize the rtc12887 once in a program. then another program will be separately written to fetch the hour and minute values. i hope u understand my program...
 

grieblm

Member level 4
Joined
May 7, 2011
Messages
75
Helped
18
Reputation
36
Reaction score
18
Trophy points
1,308
Location
Georgetown, Canada
Activity points
1,734
I guess a schematic would help me to better understand your hardware and I might be able to find a problem.
Just for fun, try to initialize the RTC and then use a loop to read and display the time -- all in one program. I have a nagging suspicion that something is not being initialized when you run your second program. Typically debuggers will assert reset lines which may be resetting the RTC chip.
 

scorchers

Newbie level 1
Joined
May 7, 2012
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,286
I guess a schematic would help me to better understand your hardware and I might be able to find a problem.
Just for fun, try to initialize the RTC and then use a loop to read and display the time -- all in one program. I have a nagging suspicion that something is not being initialized when you run your second program. Typically debuggers will assert reset lines which may be resetting the RTC chip.
Hi,
I have the same problem as the original poster. But I have programmed in Assembly language. I've tried both the methods, i.e try 2 different programs. 1 for initializing the RTC and another program for acquiring the time from RTC, and also both the programs in 1 go. But I don't know whether the RTC is switching on. Please help me out.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top