Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

internal rtc in pic18f46j11

Joined
Oct 19, 2020
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
35
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
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,443
Helped
4,744
Reputation
9,503
Reaction score
4,514
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
123,195
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.
 

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
18,391
Helped
4,104
Reputation
8,208
Reaction score
4,037
Trophy points
113
Activity points
121,080
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
 

Joined
Oct 19, 2020
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
35
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;
 

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
18,391
Helped
4,104
Reputation
8,208
Reaction score
4,037
Trophy points
113
Activity points
121,080
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
 

Joined
Oct 19, 2020
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
35
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.
 

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
18,391
Helped
4,104
Reputation
8,208
Reaction score
4,037
Trophy points
113
Activity points
121,080
Hi,

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

I'm out.

Klaus
 

Aussie Susan

Advanced Member level 4
Joined
Jan 5, 2015
Messages
1,197
Helped
366
Reputation
732
Reaction score
363
Trophy points
83
Activity points
12,979
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
 

Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top