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.

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
 

Why are you using two different programs? Shouldn't you be initializing and reading the clock in the same program?
 

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...
 

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.
 

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.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top