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

DS1302 RTC interfacing with 8051-programming in c

Status
Not open for further replies.

DrWhoF

Advanced Member level 1
Joined
May 6, 2005
Messages
402
Helped
24
Reputation
48
Reaction score
11
Trophy points
1,298
Activity points
4,388
ds12887 problem

I am testing a circuit with RTC DS12887, 87C52, 74LS373 and DS12887 on a vero-board.
I can access registers of seconds, years and control: 0A, 0B and 0C, but I can't access registers of minutes, hours, days and months. It looks like this: seconds are counting from 00 to 59 but there is no count on minutes and so on.
I can write a number to and read form (00 to 99) the years register.
I tested DS12887 in another circuit and it is OK.
Why so weird behaviour and whay can be the reason?
Thanks.
DrWho
 

IanP

Advanced Member level 5
Joined
Oct 5, 2004
Messages
7,942
Helped
2,309
Reputation
4,620
Reaction score
531
Trophy points
1,393
Location
West Coast
Activity points
66,459
ds12887 pic

Do uou have 2 of these DS12887? It doesn't make sense ..
And, what is the reason you have 74373?
The DS12877 has already built-in the multiplexed DATA/ADDRESS bus and all what you need to connect are the ALE, RD, WR and/or IRQ signals ..
Regards,
IanP
 

    DrWhoF

    points: 2
    Helpful Answer Positive Rating

DrWhoF

Advanced Member level 1
Joined
May 6, 2005
Messages
402
Helped
24
Reputation
48
Reaction score
11
Trophy points
1,298
Activity points
4,388
ds12887

I have only one DS12887 and 27C512 as external program memory (74373 is used for this purpose).
The DS12877 is connected to AD bus with all control signals in place.
As I said I can read seconds and hours and I can access all controll registers and RAM locations.
Thanks.
DrWho
 

IanP

Advanced Member level 5
Joined
Oct 5, 2004
Messages
7,942
Helped
2,309
Reputation
4,620
Reaction score
531
Trophy points
1,393
Location
West Coast
Activity points
66,459
how to use irq signal of ds12887

If you say that the DS12887 itself is not faulty then most likely you have software bugs..
Double check the sections of code where you read year, month, .., and seconds, and where you display or send somewhere results .. or if you would like post them here for verification ..

Regards,
IanP
 

    DrWhoF

    points: 2
    Helpful Answer Positive Rating

DrWhoF

Advanced Member level 1
Joined
May 6, 2005
Messages
402
Helped
24
Reputation
48
Reaction score
11
Trophy points
1,298
Activity points
4,388
ds12887 circuit

This is the code which I use to read from DS12877:
Code:
; Reading DS12887

		MOV		R0, #0Ah
Wait:		MOVX		A, @R0
		JB		ACC.7, Wait

		MOV		R0, #00h
		MOVX		A, @R0			
		MOV		MSec, A
		MOV		R0, #02h
		MOVX		A, @R0
		MOV		MMin, A
		MOV		R0, #04h
		MOVX		A, @R0
		MOV		MHour, A
		MOV		R0, #07h
		MOVX		A, @R0
		MOV		MDay, A
		MOV		R0, #08h
		MOVX		A, @R0
		MOV		MMonth, A
		MOV		R0, #09h
		MOVX		A, @R0
		MOV		MYear, A
This is the code which I use to display Date and Time:
Code:
; Date and Time transmission.

Year:		MOV		A, MYear
		SWAP		A
		ANL		A, #0Fh
		MOV		R6, A
		LCALL		Send_R6
		MOV		A, MYear
		ANL		A, #0Fh
		MOV		R6, A
		LCALL		Send_R6

		MOV		R6, #0Dh			; "-"
		LCALL		Send_R6

Month:	MOV		A, MMonth
		SWAP		A
		ANL		A, #0Fh
		MOV		R6, A
		LCALL		Send_R6
		MOV		A, MMonth
		ANL		A, #0Fh
		LCALL		Send_R6

		MOV		R6, #0Dh			; "-"
		LCALL		Send_R6

Day:		MOV		A, MDay
		SWAP		A
		ANL		A, #0Fh
		MOV		R6, A
		LCALL		Send_R6
		MOV		A, MDay
		ANL		A, #0Fh
		LCALL		Send_R6
	
Hour:		MOV		A, MHour
		SWAP		A
		ANL		A, #0Fh
		MOV		R6, A
		LCALL		Send_R6
		MOV		A, MHour
		ANL		A, #0Fh
		LCALL		Send_R6

		MOV		R6, #0Ah			; ":"
		LCALL		Send_R6

Minute:	MOV		A, MMin
		SWAP		A
		ANL		A, #0Fh
		MOV		R6, A
		LCALL		Send_R6
		MOV		A, MMin
		ANL		A, #0Fh
		LCALL		Send_R6

		MOV		R6, #0Ah			; ":"
		LCALL		Send_R6

Second:	MOV		A, MSec
		SWAP		A
		ANL		A, #0Fh
		MOV		R6, A
		LCALL		Send_R6
		MOV		A, MSec
		ANL		A, #0Fh
		MOV		R6, A
		LCALL		Send_R6

		RET
Thanks.
DrWho
 

IanP

Advanced Member level 5
Joined
Oct 5, 2004
Messages
7,942
Helped
2,309
Reputation
4,620
Reaction score
531
Trophy points
1,393
Location
West Coast
Activity points
66,459
ds12887,microchip

The code for reading the RTC looks perfectly fine ..
However, in the other section (Month, Day, Hour and Minute) after:
ANL A, #0Fh (lower nibble)
you should load R6 with A and then send R6; so, for example, Month should look like this:

Month: MOV A, MMonth
SWAP A
ANL A, #0Fh
MOV R6, A
LCALL Send_R6
MOV A, MMonth
ANL A, #0Fh
MOV R6, A
LCALL Send_R6

.. and I think there are your missing Months, Days, Hours and Minutes ..
Good Luck and Regards,
IanP
 

    DrWhoF

    points: 2
    Helpful Answer Positive Rating

DrWhoF

Advanced Member level 1
Joined
May 6, 2005
Messages
402
Helped
24
Reputation
48
Reaction score
11
Trophy points
1,298
Activity points
4,388
ds12887 code for pic

Wow, it is working.
Thank you very,very much.
DrWho
 

vratislav

Newbie level 4
Joined
Aug 22, 2005
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,328
reading ds12887

DrWhoF said:
Wow, it is working.
Thank you very,very much.
DrWho

can you send me your code for to try use a DS12887, i`m use microchip`s pic but not communicate with the device. sorry my english!!
 

IanP

Advanced Member level 5
Joined
Oct 5, 2004
Messages
7,942
Helped
2,309
Reputation
4,620
Reaction score
531
Trophy points
1,393
Location
West Coast
Activity points
66,459

    DrWhoF

    points: 2
    Helpful Answer Positive Rating

sharang

Junior Member level 1
Joined
Jun 2, 2009
Messages
18
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,405
Problem with DS12887

#include<reg51.h>
#include<absacc.h>
sbit RS=P1^2;
sbit RW=P1^3;
sbit E=P1^4;
void put(unsigned char ch,bit rs);
void delay(unsigned int t);
void init(void);
void main()
{
int i=0x00;
delay(500);
//P0=0xFF; //Input Port
init();
put('R',1);
put('T',1);
put('C',1);
put(0xC0,0);
delay(2);
XBYTE[10]=0x20;
XBYTE[11]=0x83;
XBYTE[11]=0x03;
XBYTE[0]=41;
//XBYTE[11]=0x03;
while(1)
{
put(0xC0,0);
for(i=0x00;i<0x0A;i++)
{
// XBYTE[0]++;
put((XBYTE[0]<<0x0F)+0x30,1);
delay(500);
put(0x94,0);
put((XBYTE[10]<<0x0F)+0x30,1);
}
/*if(XBYTE[0]>=0x39)
XBYTE[0]=0x30;
*/
}
}
void init(void)
{
put(0x3C,0); //Set interface length
put(0x01,0); //Clear the display
put(0x06,0); //Set cursor move direction
put(0x0E,0); //Enable display cursor
return;
}
void put(unsigned char ch,bit rs)
{
E=1;
RW=0;
P2=ch;
RS=rs;
delay(1);
E=0;
delay(1);
RW=1;
return;
}
void delay(unsigned int t)
{ unsigned int k,l;
for(l=0;l<t;l++)
for(k=0;k<900;k++);
return;
}
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top