PDA

View Full Version : RTCC Issues PIC18F67J90



walterp
- 11th May 2014, 22:11
I'm trying to use the RTCC in the PIC18F67J90 with an external 32 KHz watch crystal. I've probed the crystal with my scope and shown that the timer is running it, but for some reason the RTCC refuses to increment. I've also printed the timer1 values, it seems to be counting, but still the RTCC doesn't increment. Also I don't get a pulse output on the RTCC pin (pin 8 on this chip).

Config:

#CONFIG CONFIG OSC = HS
CONFIG LPT1OSC = OFF
CONFIG CP0 = OFF
CONFIG WDTEN = OFF
CONFIG XINST = OFF
CONFIG T1DIG = OFF
CONFIG IESO = OFF
CONFIG FCMEN = OFF
CONFIG WDTPS = 512
CONFIG RTCSOSC = T1OSCREF
CONFIG STVREN = ON
#ENDCONFIG
Initialization:


initRTCC: RTCCFG = %10000100
T1CON = %10001001
PADCFG1 = %00000010
EECON2 = $55
EECON2 = $AA
RTCCFG.5 = 0

Readout Code:


readRTC:
RTCCFG.1 = 1 : RTCCFG.0 = 1
DEBUG "RTCPRT = ", DEC RTCCFG.1, DEC RTCCFG.0, " ", "H: ", DEC RTCVALH, " L:", DEC RTCVALL,10,13
DEBUG "RTCPRT = ", DEC RTCCFG.1, DEC RTCCFG.0, " ", "H: ", DEC RTCVALH, " L:", DEC RTCVALL,10,13
DEBUG "RTCPRT = ", DEC RTCCFG.1, DEC RTCCFG.0, " ", "H: ", DEC RTCVALH, " L:", DEC RTCVALL,10,13
DEBUG "RTCPRT = ", DEC RTCCFG.1, DEC RTCCFG.0, " ", "H: ", DEC RTCVALH, " L:", DEC RTCVALL,10,13
DEBUG "Timer1: ", DEC TMR1H, ",", DEC TMR1L,10,13
DEBUG "RTC Reads: ", STR hour, ":", STR minute, ":", STR sec,10,13,10,13
pause 2000
goto readRTC
Output:


RTCPRT = 11 H: 0 L:0
RTCPRT = 10 H: 0 L:0
RTCPRT = 01 H: 0 L:0
RTCPRT = 00 H: 0 L:0
Timer1: 77,102
RTC Reads: ::


RTCPRT = 11 H: 0 L:0
RTCPRT = 10 H: 0 L:0
RTCPRT = 01 H: 0 L:0
RTCPRT = 00 H: 0 L:0
Timer1: 66,103
RTC Reads: ::

I've been beating my head against this for hours, does anyone have any insight? :confused::confused:

Thanks,
Walter

Darrel Taylor
- 12th May 2014, 21:19
Your line RTCCFG = %10000100 isn't enabling the RTCC module ...
The RTCWREN bit must be set before you can set the Enable bit (RTCCFG.7).



EECON2 = $55
EECON2 = $AA ; Unlock
RTCCFG.5 = 1 ; Enable Writes
RTCCFG.7 = 1 ; Enable RTCC module
EECON2 = $55
EECON2 = $AA
RTCCFG.5 = 0 ; Disable Writes

walterp
- 13th May 2014, 00:46
:eek: :biggrin: doh! Sure enough, it's ticking right along now. I didn't realize that register was locked too! Thanks a million!