yabo104
Joined: 17 Feb 2015 Posts: 2
|
I can't get the time with internal RTCC with PIC18F66J94 |
Posted: Tue Jun 02, 2015 5:38 pm |
|
|
Hello, I'm using internal RTC in my pic18F66J94 but when i use rtc_read(&read_clock); i get the same data which i already configured the clock. I have a 32.768 KHz crystal in the SOSC pins RC0 and RC1, with 15pf ceramic capacitors. The Vbat pin has a 3v CR2032 Battery installed, but the internal RTC doesn't start.
Anybody can help me?
http://www.ccsinfo.com/forum/viewtopic.php?t=46528
CCS compiler is 5.009
This is the configuration fuses in main.h:
Code: |
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NOCKSNOFSM //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES VREGSLEEP_SW //Ultra low-power regulator is enabled
#FUSES DSWDTOSC_SOSC
#use delay(internal = 8000000)
|
And this is the code:
Code: |
void main (){
setup_lcd(LCD_DISABLED);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_4); //131 ms overflow
setup_rtc(RTC_ENABLE , 0);
wizardTempTime.tm_year = 15;
wizardTempTime.tm_mon = 6;
wizardTempTime.tm_mday = 2;
wizardTempTime.tm_wday = 2;
wizardTempTime.tm_hour = 17;
wizardTempTime.tm_min = 58;
wizardTempTime.tm_sec = 2;
rtc_write(&wizardTempTime);
while(true){
rtc_read(&read_clock); //reads clock value from RTCC
fprintf(UART1, "\r%02u/%02u/20%02u %02u:%02u:%02u \n\r",read_clock.tm_mon,read_clock.tm_mday,read_clock.tm_year,read_clock.tm_hour,read_clock.tm_min,read_clock.tm_sec);
delay_ms(1000);
}
} |
|
|