CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Example for RTCC with PIC24FJ
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

Example for RTCC with PIC24FJ
PostPosted: Thu Feb 14, 2013 12:52 pm     Reply with quote

Hi, everyone! I have a few PIC24FJ64GA306 and I saw in the datasheet they have hardware RTCC. So can you tell me which CCS function I can use to work with this RTCC??
Thanks!
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Feb 14, 2013 12:59 pm     Reply with quote

Make sure to read the PCD Compiler Manual...

Also check the .H file for your device (it's a dead giveaway)

(hint: search for RTCC)

After doing those two things, if you still need help, I'll be happy to advise.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Fri Feb 15, 2013 1:55 am     Reply with quote

Thanks! I want to ask one more thing. The datasheet of 24FJ64GA306 (RTCC part) says :
Quote:

• Runs from any one of the following:
- External Real-Time Clock (RTC) of 32.768 kHz
- Internal 31.25 kHz LPRC clock
- 50 Hz or 60 Hz external input

So as far as I understood this I don`t have to connect external oscillator, but I can use the internal clock. Is this a good idea? Or have misunderstood the datasheet?
I`m using 24FJ controller for first time and it`s little bit different then 18F series.
Where should I connect this extra oscillator? Between PIN 42 and GRD?
I`m not sure for the connection of the controller. I have electrolite cap between pin 56(Vcap) and GRD. Pins 10, 19, 26, 38 are connected to Vcc. Pins 9, 20, 25, 41 to GRD. The main oscillator is on 39 and 40. I have resistor on pin 7 (MCLR). PIN4 of the ICSP connector is connected to PIN 16 PGED1, pin 5 to PIN 15 PGEC1. Is this correct???
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Fri Feb 15, 2013 8:22 am     Reply with quote

If you download the PIC24F Family Reference manual (Chapter/Section 29 - RTCC),

You will find on the first page is says, "Requirements: External 32.768KHz Clock Crystal"

The block diagram on the same page verifies this.

The LPRC is for running others things (namely the watchdog)

Additionally, in Chapter 6 - Oscillator (page 2, Figure 6-1), the block diagram specifically shows the LPRC oscillator does not hook up to the RTCC.

So that should answer it for ya.

Cheers,

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Fri Feb 15, 2013 8:31 am     Reply with quote

stoyanoff wrote:

Where should I connect this extra oscillator? Between PIN 42 and GRD?


MAYBE.

If you have a 32.768 KHz OSCILLATOR, then you can hook up your oscillator output to the SOSC input (but only one).

if you want to use a 32.768KHz CRYSTAL, then it needs to be hooked to BOTH SOSC inputs with addtitional capacitors as the crystal requires.

Microchip has App Notes about this. You should find them and read them.

Quote:

I`m not sure for the connection of the controller. I have electrolite cap between pin 56(Vcap) and GRD. Pins 10, 19, 26, 38 are connected to Vcc. Pins 9, 20, 25, 41 to GRD. The main oscillator is on 39 and 40. I have resistor on pin 7 (MCLR). PIN4 of the ICSP connector is connected to PIN 16 PGED1, pin 5 to PIN 15 PGEC1. Is this correct???



I believe the word you want is "electrolytic" -- and your Vcap connection is correct. What value is the capacitor. Typical recommended is 10uF. You can use Ceramic cap's here as well. (I usually do)

Next - yes. ALL VCC pins should be connected to Vcc (not just some. ALL) and every Vcc pin should have a 0.1uF or so capacitor to GND (ceramic type is fine).

There is an ICSP appnote that tells you how to hook up the PIC programmer (pretty much any of them) in terms of signal. You should review that doc as I can tell you you're missing something. (but your homework is to figure out what since I've pointed it out.)

Cheers,

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
jeremiah



Joined: 20 Jul 2010
Posts: 1345

View user's profile Send private message

PostPosted: Fri Feb 15, 2013 3:36 pm     Reply with quote

bkamen wrote:
If you download the PIC24F Family Reference manual (Chapter/Section 29 - RTCC),

You will find on the first page is says, "Requirements: External 32.768KHz Clock Crystal"

The block diagram on the same page verifies this.

The LPRC is for running others things (namely the watchdog)

Additionally, in Chapter 6 - Oscillator (page 2, Figure 6-1), the block diagram specifically shows the LPRC oscillator does not hook up to the RTCC.

So that should answer it for ya.

Cheers,

-Ben


The data sheet for this specific family has the following though:
Quote:

22.1 RTCC Source Clock
The user can select between the SOSC crystal
oscillator, LPRC internal oscillator or an external
50 Hz/60 Hz power line input as the clock reference for
the RTCC module. This gives the user an option to
trade off system cost, accuracy and power
consumption, based on the overall system needs.


Additionally, the diagram in section 22-1 of the data sheet references the LPRC as a possible source.

I cannot speak for this chip, but on the PIC24F32KA304, it has a similar option and the LPRC is fine without an external SOSC of 32kHz (again, different chip, but uses the same family reference manual). Is it possible the Family Reference manual is either inspecific or in error, or is the data sheet incorrect?
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Fri Feb 15, 2013 3:56 pm     Reply with quote

I'm going to say that my datasheet for the RTCC is old. Is the B version. I'll have to check if they've updated.

Just keep in mind the LPRC oscillator is just that, RC (Resistor-Capacitor) and it's accuracy may be less than stellar.

Otherwise, according to the device specific datasheet (which I just downloaded) looks like the LPRC is a valid RTCC Source.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
jeremiah



Joined: 20 Jul 2010
Posts: 1345

View user's profile Send private message

PostPosted: Fri Feb 15, 2013 6:11 pm     Reply with quote

Yeah, the accuracy on the internal is pretty bad...I want to say +-15% tolerance if I remember right? I only use it for coming out of deep sleep on an interval that doesn't require accuracy (like if I just need to wake up once a second or so and it's not critical that it is exactly a second).

To the opening poster:
take a look at the function setup_rtc in both the compiler manual/help index and in the .h file for your chip. It'll highlight the RTC functions and their options
Lykos1986



Joined: 26 Nov 2005
Posts: 68

View user's profile Send private message

PostPosted: Mon Jun 24, 2013 5:59 am     Reply with quote

Hi! This an old post but I've just resurrected because I am having the same problem.

I am using an 24F32KA304 and I can use the LPRC (page 185 of the datasheet) as a clock source for the internal RTC. As far as I am understanding this will be totally independent of the my primary 12MHz crystal clock and I can still use this 16MHz clock for all the other operations of my program.

How I can use this LPRC for my RTC? I know that the LPRC is not an acurate source for timing but I don't care so much for the RTC accuracy
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Jun 24, 2013 6:18 am     Reply with quote

#fuses RTCOSC_LPRC// RTCC uses LPRC as reference clock
Lykos1986



Joined: 26 Nov 2005
Posts: 68

View user's profile Send private message

PostPosted: Mon Jun 24, 2013 6:49 am     Reply with quote

It produces an error (Unknown keyword on MpLab) when I am using this fuse.

Also I was trying to find this fuse using the CCS IDE at the "Valid Fuses" section and there is not there as well.

I am using version 4.14 of CCS.
dyeatman



Joined: 06 Sep 2003
Posts: 1933
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Jun 24, 2013 8:27 am     Reply with quote

Are you using 4.014 or 4.140?
_________________
Google and Forum Search are some of your best tools!!!!
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Jun 24, 2013 8:41 am     Reply with quote

Yes, you are right, I was referring to a different 24F chip. With 24F32KA304, the RTCC clock
source is selected in RTCPWC register. Refer to datasheet chapter 19. Don't know if it's supported
by setup_rtc(). In case of doubt, set the SFR directly.
Lykos1986



Joined: 26 Nov 2005
Posts: 68

View user's profile Send private message

PostPosted: Mon Jun 24, 2013 9:22 am     Reply with quote

I am using the 4.140.

I will try to set the SFR directly. In case you have any news in the mean time please let me know.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Jun 24, 2013 12:46 pm     Reply with quote

setup_rtc() seems no prepared to write RTCPWC register. When writing directly to SFR, you also have to reset the write lock.

There's another issue with setup_rtc() that is setting OSCCON.SOSCEN which is not suitable for LPRC operation.
All in all, it's probably better to do the complete RTCC setup manually.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group