Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

rtcc programing for pic 18f46j11

Status
Not open for further replies.

ruchi7

Newbie level 2
Joined
Jul 7, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,300
i am trying to set time in internal rtcc of pic18f46j11.

i can configure the rtcc configuration register but i am not able to load values in rtcvall and rtcvalh registers.

the code i have used is:

#include<P18F46J11.INC>
CONFIG OSC=HS
REC_VALUE EQU 0X20;the value received at
;Rx1 will be tansfered to this register
;RTCCFG EQU 0XF3F; RTCC CONFIGURATION REGISTER
;RTCVALL EQU 0XF98; RTCC LOWER VALUE REGISTER
;RTCVALH EQU 0XF99; RTCC HIGHER VALUE REGISTER
ORG 0
;******************************************************************
;setting date and time
;******************************************************************


movlb 0x0f
movlw 0x55
movwf EECON2,0
movlw 0xAA
movwf EECON2,0
bsf RTCCFG,5,1
BSF RTCCFG,1,1
BSF RTCCFG,0,1
MOVLW B'00010010'
MOVWF RTCVALL ;SETTING THE YEAR
MOVLW 0X00
MOVWF RTCVALH
MOVLW B'00001001'
MOVWF RTCVALL ;SETTING THE DATE
MOVLW B'00000001'
MOVWF RTCVALH ;SETTING THE MONTH
MOVLW B'00010010'
MOVWF RTCVALL ;SETTING HOURS
MOVLW B'00000001'
MOVWF RTCVALH ;SETTING WEEKDAY
MOVLW B'01010000'
MOVWF RTCVALH ;SETTING MINUTES
MOVLW B'01000000'
MOVWF RTCVALL ;SETTING SECONDS
 

That code is correct but how do you know if the values are loaded properly?
I'm not sure MPLAB simulates the RTCC registers fully. Also be aware that you cannot use the internal low speed oscillator as the clock source if you want to keep good time. It runs at 31KHz, not the necessary 32.768KHz you need for accurate timekeeping.

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top