View previous topic :: View next topic |
Author |
Message |
heUAcyp
Joined: 16 Mar 2011 Posts: 33
|
setting up RTCC - PIC 18F24J11- timer -- please!! |
Posted: Wed Mar 16, 2011 11:20 am |
|
|
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
|
|
Posted: Wed Mar 16, 2011 2:14 pm |
|
|
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
|
rtcc.c |
Posted: Wed Mar 23, 2011 12:10 pm |
|
|
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
|
|
Posted: Wed Mar 23, 2011 12:12 pm |
|
|
You need a more recent version of the compiler. |
|
|
heUAcyp
Joined: 16 Mar 2011 Posts: 33
|
PicKit_2 |
Posted: Wed Mar 23, 2011 12:14 pm |
|
|
if I find ex_rtcc.c, I can still compile using PICkit 2 right? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 23, 2011 12:35 pm |
|
|
PicKit 2 is a programmer, not a compiler. |
|
|
heUAcyp
Joined: 16 Mar 2011 Posts: 33
|
ex_rtcc.c |
Posted: Wed Mar 23, 2011 12:42 pm |
|
|
how can I find ex_rtcc.c file then boss? I really really do need that. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 23, 2011 12:55 pm |
|
|
Get a more recent version of the compiler. I can't help any more. |
|
|
heUAcyp
Joined: 16 Mar 2011 Posts: 33
|
|
Posted: Wed Mar 23, 2011 12:56 pm |
|
|
Thanks for your help |
|
|
heUAcyp
Joined: 16 Mar 2011 Posts: 33
|
last question |
Posted: Wed Mar 23, 2011 1:55 pm |
|
|
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
|
|
Posted: Wed Mar 23, 2011 2:08 pm |
|
|
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
|
|
Posted: Wed Mar 23, 2011 3:11 pm |
|
|
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
|
|
Posted: Wed Mar 23, 2011 3:32 pm |
|
|
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
|
Compiler version |
Posted: Wed Mar 23, 2011 3:46 pm |
|
|
Compiler version is V 4.087 , do I need a newer version? |
|
|
heUAcyp
Joined: 16 Mar 2011 Posts: 33
|
|
Posted: Wed Mar 30, 2011 1:33 pm |
|
|
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? |
|
|
|