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.

internal rtc in pic18f46j11

Status
Not open for further replies.
Joined
Oct 19, 2020
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
38
hello
ALRMCFG=0X8A;
PADCFG1=0X05;
RTCCFG=0X86;
I configure following above register,I am using mplab x ide,please clarify that how to use internal rtc in pic18f46j11..and also I have searched the sample code in internet to clarification,but not yet to get,please any one help me
 

The data sheet does explain it in detail but it is quite complicated.

I'm not sure what you want to achieve but I would guess you are having trouble writing and reading the time and date registers. They are all addressed at RTCVALH:RTCVALL (16 bits as two 8 bit values) but the actual register you are using is selected by the RTCPTR 1:0 bits.

You set the register you want to use with the RTCPTR bits then read and write the value through RTCVAL. The same applies to the ALRMPTR and ALRMVAL registers.

Brian.
 

Hi,

I have not much experience with PIC, but had a quick look through the datasheet.

Besides the code the RTC needs some hardware like: continous power supply, external 32768Hz XTAL.
Also special care in hardware and software needs to be taken to reduce power consumption.

Because of this I found external RTC more simple to use.

Klaus
 

hello
i have tried the follwing below code to run the internal rtc in pic18f46j11 ,but I have little confusion about read and write register.can anyone help me whether code is right or wrong..

RTCCFG=0X24;
delay(10000);
PADCFG1=0X04;
T1CON=0X8c;
RTCWREN=0;
RTCEN=1;
delay(10000);
sec=RTCVALL;
min=RTCVALH;
 

Hi,

It still is not clear what you want to achieve.
All we see are just a couple of code lines, but no error description, no clear question.

Please show the whole code and tell which compiler you use.
Tell what you expect and what you see instead.

Klaus
 

thank you,i am using PIC18F46J11 in mp lab x ide xc8 compiler,i want to display a time and date using internal rtc itself.display is nokia 5110 lcd.my code is uploaded below which i am tried,i have some issues to get rtc data.
 

Hi,

With the provided informations nobody can help, because nobody knows what's the problem or what information you need ...

I'm out.

Klaus
 

Without seeing all of the code, I think there is one fundamental problem you are facing: you either have not read the data sheet section for the RTCC, or you do not understand it.
Please read Section 17.2.7 as it shows how to properly unlock the RTCCFG register.
I am not that familiar with the XC8 compiler but I believe there are library calls such as 'RtccWrOn()' that can unlock the RTCCFG register. If not then you may need to learn how to embed the assembler instructions in the data sheet. (You may be tempted to just write the equivalent C code but be warned that the generated code may not work - unlocking the RTCCFG register requires that some of the code is executed in consecutive machine instructions - something the C compiler is not required to do.)
Therefore you need to first unlock the RTCCFG, set the RTCWREN bit and THEN set up the other bits, in particular the RTCEN bit.
I note that your code sequence in post #4 explicitly clears the RCTWREN bit and tries to write to the RTCEN bit - as stated in the first sentence of Section 17.1.4, the write to RTCEN with the RTCWREN bit clear is explicitly ignored.
There is also another approach you can take: use the MCC to generate the RTCC code for you. If you are wanting to simply get code that 'works' then this may be the way to go. If you want to write your own code, then you can use the MCC generated code as an example, study it and understand what it is doing and then try your own code.
Susan
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top