electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

rtc_get_time(hr,min,sec)


Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> rtc_get_time(hr,min,sec)
Author Message
weber



Joined: 09 Jun 2005
Posts: 1


Post02 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


Post04 Jul 2005 12:31   

rtc_set_datetime


i think you need to remove the ; after for(;Wink and this will work
Back to top
Google
AdSense
Google Adsense




Post04 Jul 2005 12:31   

Ads




Back to top
chints



Joined: 04 Jul 2005
Posts: 5


Post04 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


Post05 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(;Wink;
{

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
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> rtc_get_time(hr,min,sec)
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
HELP 555 TIMER to switch relay OFF for 20 min ON for 5 sec (1)
0.2m Sec (19)
16bit >10k samples/sec ADC? (2)
What does volt-µsec tell? (2)
Installation fails after 100 sec........... (2)
2Mega Pixel 15Frame/sec Transmit (2)
JNCIS SEC (JUNOS-331) Dumps Required (1)
What do I need to make a 555 to output a 1 sec pulse? (15)
help needed to sort out number of atoms/sec (1)
xtal(oscillator problem) - a way to generate 1 sec delay (2)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS