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

Setting up RTC Interrupt

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mayur.k.vadukul



Joined: 07 Jul 2022
Posts: 40

View user's profile Send private message

Setting up RTC Interrupt
PostPosted: Tue Aug 09, 2022 4:56 am     Reply with quote

Hi All,

I am new to CCS. So far, I have managed to move most codes to CCS. However stuck at one point whereby my RTC Alarm Interrupt does not work in CCS.

My fuses are set to use the internal 31KHz crystal. I do not need accurate alarm so I can afford to do this.

Then the code for setting up interrupt is as below:-

Code:
rtc_time_t ALARM_SETTINGS;


{
setup_rtc(RTC_ENABLE,0x00);   //Enable RTC with no calibration.
   
   setup_rtc_alarm (RTC_ALARM_DISABLE|RTC_CHIME_DISABLE, RTC_ALARM_WEEK, 0); // Weekly Alarm and No Repeat. Alarm Disabled
   
   

 
   ALRMVAL_WWHH = 0x00; // These values will be calculated in my code depending on entries. However to get it going, I have set it up as 3 secs.
   ALRMVAL_MMSS = 0x0003;
   
   ALARM_SETTINGS.tm_year = 0x14;
   ALARM_SETTINGS.tm_mon = 0x01;
   ALARM_SETTINGS.tm_mday = 0x01;
   ALARM_SETTINGS.tm_wday = ALARM_WEEK(ALRMVAL_WWHH);
   ALARM_SETTINGS.tm_hour = ALARM_HOURS(ALRMVAL_WWHH);
   ALARM_SETTINGS.tm_min = ALARM_MINS(ALRMVAL_MMSS);
   ALARM_SETTINGS.tm_sec = ALARM_SECS(ALRMVAL_MMSS);
   
   rtc_alarm_write(&ALARM_SETTINGS);
 
   setup_rtc_alarm (RTC_ALARM_ENABLE|RTC_CHIME_DISABLE, RTC_ALARM_WEEK, 0); // Weekly Alarm and No Repeat. Alarm Disabled
   enable_interrupts (INT_RTC);

}


The interrupt routine is written under:-

#INT_RTC
void RTC_isr (void)
{

}

I am using PIC18F66K22. Any thoughts would be appreciated.
_________________
MVadukul
Ttelmah



Joined: 11 Mar 2010
Posts: 19544

View user's profile Send private message

PostPosted: Tue Aug 09, 2022 5:53 am     Reply with quote

The chip does _not_ have an "internal 31KHz crystal". It has a relatively
poor internal 31K oscillator, but this is not even remotely good enough
really for an RTC.

However assuming you have got the RTC to work with the internal
oscillator, the alarm is quite non intuitive. The mask controlling how it
triggers takes a lot of getting your head round. Have a look at this
thread and in particular Jay's comment on this.

[url]
http://www.ccsinfo.com/forum/viewtopic.php?t=57354&highlight=setuprtc
[/url]

I suspect this is your problem.
mayur.k.vadukul



Joined: 07 Jul 2022
Posts: 40

View user's profile Send private message

Setting up RTC Interrupt
PostPosted: Tue Aug 09, 2022 6:31 am     Reply with quote

I should have used the term Internal Oscillator for RTCC.

I can't tell whether my RTCC module is working or not in CCS as I am using the pins on the board, which could output the RTCC pulse.

I have run RTCC module and RTC alarm interrupt in the MPLAB, so surely it works. Its just that now i am using CCS, and but do not know how to adjust the ALRMPTR values and the operation.
_________________
MVadukul
Ttelmah



Joined: 11 Mar 2010
Posts: 19544

View user's profile Send private message

PostPosted: Tue Aug 09, 2022 9:45 am     Reply with quote

If you read the manual entry for the RTC, it says it _requires_ an external
32767Hz crystal. I have never looked at trying to run it from the internal
oscillator so cannot say if this is possible. Suspect it is not.
The way to test is simple start it up, read the time, Delay for a few
seconds, and read the time again. If it has changed, you have a running
RTC. You need to test this before trying to use alarms.
mayur.k.vadukul



Joined: 07 Jul 2022
Posts: 40

View user's profile Send private message

Setting up RTC Interrupt
PostPosted: Tue Aug 09, 2022 9:49 am     Reply with quote

I now got it going.

The issue was the way RTC Settings were written in the code.

It is possible to Run RTCC module with internal oscillator. It is not accurate. I don't need accuracy so it works to the satisfactory level.

It works the worst when running in sleep mode and with low current settings. i.e. unreliable to the level whereby it works literally double the time than the set duration.
_________________
MVadukul
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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