| Author |
Message |
weber
Joined: 09 Jun 2005 Posts: 1
|
02 Jul 2005 11:10 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
|
|
| Back to top |
|
 |
armsgroup
Joined: 27 Feb 2003 Posts: 153 Helped: 8
|
04 Jul 2005 12:31 rtc_set_datetime |
|
|
|
|
i think you need to remove the ; after for(; and this will work
|
|
| Back to top |
|
 |
Google AdSense

|
04 Jul 2005 12:31 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
chints
Joined: 04 Jul 2005 Posts: 5
|
04 Jul 2005 13:47 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..
|
|
| Back to top |
|
 |
martinisonline
Joined: 24 Apr 2005 Posts: 48 Location: Portugal
|
05 Jul 2005 3:23 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(y);
delay_ms(500)
}
}
|
|
| Back to top |
|
 |