|
|
View previous topic :: View next topic |
Author |
Message |
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
RTC causes problems with different CCS versions |
Posted: Wed Feb 19, 2014 4:48 am |
|
|
Greetings! Until now I used CCS v4.134 and MPlab v8.91. I have a board with PIC24FJ64GA306. Here is a code example:
Code: |
#include <24FJ64GA306.h>
#FUSES HS,WDT_SW,WPOSTS8,PR
//#FUSES HS,NOWDT,PR
#use delay(clock=20M)
#use I2C(MASTER,SCL=PIN_G2,SDA=PIN_G3,FORCE_SW)
int year,month,day,hour,minutes,sek;
rtc_time_t write_clock, read_clock;
void SetRTCC()
{
write_clock.tm_year=year;
write_clock.tm_mon=month;
write_clock.tm_mday=day;
write_clock.tm_hour=hour;
write_clock.tm_min=minutes;
write_clock.tm_sec=0;
rtc_write(&write_clock);
}
void ReadRTCC()
{
rtc_read(&read_clock);
year=read_clock.tm_year;
month=read_clock.tm_mon;
day=read_clock.tm_mday;
hour=read_clock.tm_hour;
minutes=read_clock.tm_min;
sek=read_clock.tm_sec;
}
void SetupRTC()
{
setup_rtc(RTC_ENABLE);
}
void main()
{
year=0;
minutes=0;
hour=0;
day=1;
month=1;
SetupRTC();
SetRTCC();
while(1)
{
delay_ms(20000);
ReadRTCC();
}
}
|
With v4.134 this code works fine. Now I have v5.012! With this version the RTC doesn`t count. I change the .h file with the newer from v5.012 - no change! Is this a glitch or I`m doing something wrong?!
Thanks! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Wed Feb 19, 2014 7:04 am |
|
|
hmm..since the code worked fine with 4.134 I have to ask WHY did you change the 24FJ64GA306.h file?
Although I'm using an older v4 version, I've never had to change PIC header files to use newer compiler versions.
I'd printout both v4 and v5 versions of it,just to see the differences though.
hth
jay |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Wed Feb 19, 2014 7:22 am |
|
|
I changed the .h file after I found out it didn`t work! Are there any changes in the way of setting the RTC?! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Wed Feb 19, 2014 7:33 am |
|
|
sorry, I can't help except as I said, dump out the header files and compare the RTC sections.
hopefully someone that uses the 24 series will be able to help soon !
hth
jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19544
|
|
Posted: Wed Feb 19, 2014 10:08 am |
|
|
The only major difference in the code is part of the initialisation. The older compiler repeats the initialisation of some registers twice:
Code: |
031C: MOV #2780,W15
031E: MOV #27FF,W0
0320: MOV W0,20
0322: NOP
0324: MOV #2780,W15
0326: MOV #27FF,W0
0328: MOV W0,20
032A: NOP
|
While the newer one only does this once.
Can't see any erratum that would explain their doing this.
The actual RTC setting code is identical between the compiler (well between the versions I can test 5.013, don't have 5.012, and 4.135 - again don't have 4.134). In fact if you run MPLAB, and put a breakpoint at the start of the delay, all the RTC registers have the same values with both versions... |
|
|
|
|
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
|