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 DS12887A and PIC16F877A! need help please...

Status
Not open for further replies.

cutemint

Newbie level 4
Newbie level 4
Joined
Feb 23, 2009
Messages
5
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,312
Can anyone give me a circuit and a simple program (MikroC) for reading the time and date of the RTC? i think im having troubles, i seem cant to get the right output. First of all, IDK how RTC works (noob). Please and Thank You...
 

I don’t think many PIC-users are keen to employ the DS12887 ..
This IC (and all others from the same family) have implemented multiplexed address/data bus and ideal to work with 80-xxx series, eg. 8051-derivatives ..

But, with microcontroller almost anything is possible ..
Try to follow the attached procedure and see how it goes:
Pick a port with all 8 port bits available and 4 other pins (if you don't plan on using the interrupt output). 3 of these pins can be used for other things (they are inputs to the device so are high impedance but need to be drivable by the PIC). (ALE -RD -WR)

First set your direction on the 8 bit data port for output
Set ALE to LOW SET -RD and -WR HIGH
Set -CS Low now
Write your address location to the data port
Set ALE to HIGH
Set ALE to LOW

Now if you wish to write to this address write the data to the data port
Set -WR LOW
Set -WR HIGH

if you wish to read from this address
Set the direction of the Data Port to inputs
Set -RD LOW
Read the Data port state to wherever
Set -RD HIGH

Now you are done set -CS high
set the Data port as inputs (let the bus go)
You can now use all those pins except the -CS pin for other things (within reason of course)

That about sums it up.. you can read and write any register with that algorythm..
here is a BIG HINT .. go to page 29 of the Data sheet and READ it. So you understand how the bus works.
Another BIG HINT, read the WHOLE DATA SHEET, or you WILL be asking questions again in a matter of minutes to hours.

IanP
:wink:
 
  • Like
Reactions: DrWhoF

    DrWhoF

    Points: 2
    Helpful Answer Positive Rating
i found another simple guide https://www.edaboard.com/threads/66517/ , but there seems to be something wrong. i converted his code to mikroC, and the result was a constant output. heres the code i made:

void main()
{
int i;

TRISB=0x00;

for(i=0;i<5;i++)
{
PORTB=0x00;
delay_ms(500);
PORTB=0xFF;
delay_ms(500);
}

PORTB=0x00;

while(1)
{
TRISC=0x00;
PORTC=0x00;
PORTD.F7=0;
TRISC=0xFF;
PORTD.F6=0;
PORTB=PORTC;
PORTD.F6=1;
PORTD.F7=1;
}

for(i=0;i<256;i++)
{
PORTB=i;
delay_ms(200);
}

}

the pinouts are:
AD0-7 --- PORTC
AS --- PORTD.F7
DS --- PORTD.F6

my aim was to display in portb whatever the seconds output in the DS12887A.
the problem was it only display a constant output of 01011110 in the LEDs.

Please help :(
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top