rtc_get_time(hr,min,sec)

Status
Not open for further replies.

weber

Newbie level 3
Joined
Jun 9, 2005
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,302
rtc_get_time

i write this code in ccs-c but it didnt work
Code:
#include <16f84a.h>
#fuses Hs,NOWDT,NOPROTECT
#use delay(clock=4000000)
#byte  PORTA = 5
#byte  PORTB = 6
#include <DS1302a.c>

   main(void)
{

char x,y,z;
rtc_init();
rtc_set_datetime(8,9,9,5,0,0);
portb=0;
SET_TRIS_B(0);


for(;;);
{

rtc_get_time(x, y, z);

if(y = 00) output_high(PIN_B0);
else
output_low(PIN_B0);
}

}
the question is how can i appoint values like x,y,z from rtc_get_time(hr,min,sec) function.i sumulated this program with proteus,i can set date and time ,it works very well,but i didnt get values from ds1302
 

rtc_set_datetime

i think you need to remove the ; after for(; and this will work
 

rtc_get_time

I am able to see following errors

1)
; after for loop -> may result end less loop

2) rtc_get_time(x, y, z);
how can x,y,z can be updated in rtc_get_time functions. I suspect they may be pointers, try
rtc_get_time(&x, &y, &z) -> may work

This point is applicable if you not using C++ and ref.. in place of pointers..
 

5 min = ? sec

----YOUR CODE------

#include <16f84a.h>
#fuses Hs,NOWDT,NOPROTECT <----if you use a 4Mhz cristal, its XT
#use delay(clock=4000000)
#byte PORTA = 5
#byte PORTB = 6
#include <DS1302a.c> <------in my ccs, this driver doesn't exist!!!

main(void)
{

char x,y,z; <-------------- try a 'int' or 'byte' variable
rtc_init();
rtc_set_datetime(8,9,9,5,0,0);
portb=0;
SET_TRIS_B(0);


for(;;
{

rtc_get_time(x, y, z);

if(y = 00) output_high(PIN_B0);
else
output_low(PIN_B0);
}

}
----------------

I have no sure, but try this code modifyed, and connect 8 leds at port_b and verify if they blink....

#include <16f84a.h>
#fuses XT,NOWDT,NOPROTECT
#use delay(clock=4000000)
#byte PORTA = 5
#byte PORTB = 6
#include <ds1302.c>

main(void)
{

byte x,y,z;
rtc_init();
rtc_set_datetime(8,9,9,5,0,0);
portb=0;
SET_TRIS_B(0);


while(TRUE)
{

rtc_get_time(x, y, z);

output_b;
delay_ms(500)
}

}
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…