Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PIC18F27J53 RTCC not working
18-06-2015, 10:47 AM, (This post was last modified: 19-06-2015, 04:22 AM by kaza007.)
#1
PIC18F27J53 RTCC not working
Hi all,
I am trying to test the RTTC of an 18f27j53 setup. Using the following

Pinguino 27j53 - DIY (same as 47j53 config)
Bootloader_v4.14_18f27j53_X8MHz.hex
Win 8.1
Pinguino IDE, 11.0-beta.3 and Pinguino-X4-EasyPack-Win32-Rev999-v01-2014-04

Used the blink.pde successfully. My code is below. No errors on compile and uploads OK.
When using terminal, the time and date are always 00.00.00.
Noticed curTime and curDate are not assigned any values. Tried using convertTime and convertDate with no success.

Has anyone managed to get RTCC working on 27j53?

Code:
/* ----------------------------------------------------------------------------
FILE:   rtcc_test.pde
PROJECT: Pinguino
PURPOSE: Real Time Clock and Calendar functions Demo
PROGRAMER: regis blanchot <rblanchot@gmail.com>
DOCUMENTATION: mark harper
BOARD: PIC18F27J53-PINGUINO with external 32.768 kHz clock crystal
--------------------------------------------------------------------------
                   Code extract from RealTimeClock.pde for PIC32
                   
                   Testing 18f27j53 with RTCC
--------------------------------------------------------------------------*/


char Day[7][5] = {"Sat","Sun","Mon","Tue","Wed","Thu","Fri"};
char Month[13][5] = {"","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};

int LoopDelay = 500; // Used to slow down loop so that can see
// cat /dev/ttyACM0 output more easily
// 500 corresponds to two lines of output per second
void blink1()
{
toggle(USERLED);
}

void setup()
{
                               // Tm = 0xHHMMSS00
u32 Tm   = 0x23580000; // 23hr, 58 min, 00 sec
                               //Dt = 0xYYMMDD0W
u32 Dt   = 0x11123100; // Saturday (day 0 of the week), 31 Dec 2011
u32 aTm = 0x01091500; // 00hr, 09 min, 15 sec
u32 aDt = 0x12010101; // Sunday (day 1 of the week), 01 Jan 2012 (Year ignored)

u16 drift = 200; // add 200 pulse every minute to adjust time

/** -----------------------------------------------------------------------------
alarm will toggle the built-in led
---------------------------------------------------------------------------*/
pinMode(USERLED, OUTPUT);
digitalWrite(USERLED, OFF); // we start with led off

/** -----------------------------------------------------------------------------
set date, time and calibration
---------------------------------------------------------------------------*/
                   RTCC.open(Tm,Dt,drift);

blink1(); // Very short flash

}

void loop()
{
u8 status;
rtccTime cT, aT;
rtccDate cD, aD;
rtccTime curTime, alTime;
rtccDate curDate, alDate;

/** -----------------------------------------------------------------------------
get time and date
---------------------------------------------------------------------------*/

RTCC.getTimeDate(&cT, &cD);
                   //curTime = RTCC.convertTime(&cT);    // convert time from bcd to decimal format
                   //curDate = RTCC.convertDate(&cD);    // convert date from bcd to decimal format
CDC.printf("RTC now is ");
CDC.printf("%03s, %02d %03s %04d, ", Day[curDate.dayofweek], curDate.dayofmonth, Month[curDate.month], curDate.year+2000);
CDC.printf("%02d:%02d:%02d  \n\r", curTime.hours, curTime.minutes, curTime.seconds);

delay(LoopDelay); // Slows looping rate
}
Choose a job you love, and you will never have to work a day in your life.
- Confucius -
Reply
19-06-2015, 08:54 AM, (This post was last modified: 19-06-2015, 08:58 AM by regis.)
#2
RE: PIC18F27J53 RTCC not working
You init the RTCC lib. with :


Code:
RTCC.getTimeDate(&cT, &cD);

but you get the time and date from curDate and curTime.

So try with :


Code:
RTCC.getTimeDate(&curTime, &curDate);

and everything should be allright.
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
19-06-2015, 11:09 AM,
#3
RE: PIC18F27J53 RTCC not working
Thanks Regis.
It works nicely now.

I thought using the P32 example would work straight away. Oh well, you live and you learn!

Cheers,
Arthur
Choose a job you love, and you will never have to work a day in your life.
- Confucius -
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)