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 support@ccsinfo.com

setting up RTCC - PIC 18F24J11- timer -- please!!
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
heUAcyp



Joined: 16 Mar 2011
Posts: 33

View user's profile Send private message

setting up RTCC - PIC 18F24J11- timer -- please!!
PostPosted: Wed Mar 16, 2011 11:20 am     Reply with quote

Hi all,

This is my first post on this forum, and I would be glad if anyone can answer my easy question.

I am using PIC 18F24J11 , which has a real-time calendar clock embedded.

I got the required 32.768 kHz Xtal connecting:

PIN 11 (RC0/T1OSO/T1CKI/RP11) and
PIN 12 (RC1/T1OSI/RP12) then each to ground with 12.5 pF capacitors.

I need to keep track of real time in sleep mode using this external Xtal.

I really need your help guyz, bcz could not figure out.

Thanks in advance
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 16, 2011 2:14 pm     Reply with quote

Always look in the Examples and/or the Drivers directory for sample code:
Here is a CCS program for the internal RTC on the 18F26J11 series PICs:
Quote:

c:\program files\picc\examples\ex_rtcc.c
heUAcyp



Joined: 16 Mar 2011
Posts: 33

View user's profile Send private message

rtcc.c
PostPosted: Wed Mar 23, 2011 12:10 pm     Reply with quote

Hi, thanks for the reply

I do have ex_rtc.c , ex_rtclk.c , ex_rtctimer.c but not ex_rtcc.c .

And I think they are not same. How can I find ex_rtcc.c ?

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 23, 2011 12:12 pm     Reply with quote

You need a more recent version of the compiler.
heUAcyp



Joined: 16 Mar 2011
Posts: 33

View user's profile Send private message

PicKit_2
PostPosted: Wed Mar 23, 2011 12:14 pm     Reply with quote

if I find ex_rtcc.c, I can still compile using PICkit 2 right?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 23, 2011 12:35 pm     Reply with quote

PicKit 2 is a programmer, not a compiler.
heUAcyp



Joined: 16 Mar 2011
Posts: 33

View user's profile Send private message

ex_rtcc.c
PostPosted: Wed Mar 23, 2011 12:42 pm     Reply with quote

how can I find ex_rtcc.c file then boss? I really really do need that.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 23, 2011 12:55 pm     Reply with quote

Get a more recent version of the compiler. I can't help any more.
heUAcyp



Joined: 16 Mar 2011
Posts: 33

View user's profile Send private message

PostPosted: Wed Mar 23, 2011 12:56 pm     Reply with quote

Thanks for your help
heUAcyp



Joined: 16 Mar 2011
Posts: 33

View user's profile Send private message

last question
PostPosted: Wed Mar 23, 2011 1:55 pm     Reply with quote

PCM may I ask a last question?

What does ex_rtcc.c has and ex_rtc.c does not?

thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 23, 2011 2:08 pm     Reply with quote

Ex_rtc.c is an example file that is used with the nju6355. driver file.
The nju6355 is serial RTC chip. This is the data sheet for it.
http://www.qsl.net/df7tv/datasheets/nju6355ed.pdf
This is not what you want, and it is useless for your project.


Your PIC, the 18F24J11, has a built-in RTC section inside the PIC package.
The file, Ex_rtcc.c, calls built-in functions in (some versions) of the CCS
compiler that talk to the built-in RTC in the 18F24J11. The RTC functions
are described in the CCS compiler manual. The Ex_rtcc.c program calls
the following functions which talk to the RTC module:
Code:

setup_rtc();   
rtc_write();
rtc_read();


The CCS manual lists the following functions for the built-in RTC module
in the 18F24J11.
Code:

REAL TIME CLOCK CALENDAR

setup_rtc( )
rtc_read( )
rtc_write( )
rtc_alarm_read( )
rtc_alarm_write( )
setup_rtc_alarm( )


To use these functions, you must have a recent version of the compiler
that supports them. Also, CCS must have correctly written the functions
and tested them, so they work in whatever version you are using.
heUAcyp



Joined: 16 Mar 2011
Posts: 33

View user's profile Send private message

PostPosted: Wed Mar 23, 2011 3:11 pm     Reply with quote

Thanks for the reply again!

This is my code:

Code:
#include <18F24J11.h>
#device ADC=10
#include <STDIO.H>
#include <stdlib.h>
#include <math.h>
#include <STRING.H>
#fuses HS,NOWDT,NOPROTECT
#use delay(clock=20000000)
#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7)

void main()
{

time_t ti={0,0,0,0,0,0,0,0,0};
setup_rtc(RTC_ENABLE,RTCC_INTERNAL);
rtc_write(&ti);

while(true)
{
enable_interrupts(global);
rtc_read(&ti);
printf("%u\r\n",ti.tm_sec);
}

}


I just want to see seconds incrementing on HyperTerminal but I cannot.
Code is running , no errors - no warnings. How can I check if its working fine?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 23, 2011 3:32 pm     Reply with quote

Quote:
enable_interrupts(global);

Why are you enabling interrupts ? You don't have an interrupt service
routine. What could interrupts possibly do, without that routine ?


Also, what is your compiler version ? Your version may not completly
support the internal RTC.
heUAcyp



Joined: 16 Mar 2011
Posts: 33

View user's profile Send private message

Compiler version
PostPosted: Wed Mar 23, 2011 3:46 pm     Reply with quote

Compiler version is V 4.087 , do I need a newer version?
heUAcyp



Joined: 16 Mar 2011
Posts: 33

View user's profile Send private message

PostPosted: Wed Mar 30, 2011 1:33 pm     Reply with quote

PCM , As suggested on previous topic, I now have compiler v 4.095.

for the code I have posted above, I keep getting Error 54 : Expecting a variable.

In the header file:

I have:

Code:
typedef struct {
   int8 tm_year;
   int8 tm_yday;  // Not used by built in functions
   int8 tm_mday;
   int8 tm_mon;
   int8 tm_hour;
   int8 tm_wday;
   int8 tm_sec;
   int8 tm_min;
   int8 tm_isdst; // Not used by built in functions
} time_t;


but I could not specify using struct. How can I resolve this?
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