How to use RTC many times ?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
urchc_1533771
Level 5
Level 5
5 likes given First like received First like given

What to do if I need to use RTC as timer each time I receive event ?  All this code ? :

   

 RTC_Start(); 

   

RTC_SetDateAndTime ....

   

RTC_SetAlarmHandler(AlarmIsrHandler);

   

 

   

 

   

.

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

When you really need an RTC (which contains a calendar, provisions for DST and other features) you will need to set the alarm time (nothing else, the RTC is still running).

   

When you just need a timer, that will wake you up in a couple of minutes (eggs boiled ready) there are other, easier ways to program that.

   

 

   

Bob

View solution in original post

0 Likes
9 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

When you really need an RTC (which contains a calendar, provisions for DST and other features) you will need to set the alarm time (nothing else, the RTC is still running).

   

When you just need a timer, that will wake you up in a couple of minutes (eggs boiled ready) there are other, easier ways to program that.

   

 

   

Bob

0 Likes
urchc_1533771
Level 5
Level 5
5 likes given First like received First like given

I need RTC . How I separate  Initialization from runtime ?

   

What commands need place in Initialization routine and what commands in event handler ?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Did you look into the datasheet to get some insight into this component?

   

Apart from design-time settings as DST the initialization is only Start() and setting the current date and time.

   

All other is done at request as setting the alarm and reacting when an alarm happens.

   

 

   

Bob

0 Likes
urchc_1533771
Level 5
Level 5
5 likes given First like received First like given

I read datasheet many times but not clear.  RTC_Start() is Starts the RTC_P4 component but I`m not see function that start alarm !

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You have to set the alarm mask which allows you to specify how often an alarm will occur

   

and

   

you have to provide the alarm handler which will be called back by the RTC component.

   

I admit that it can be difficult to read English manuals, so what if you get some help from a colleague for translating.

   

Additionally it could help to open the datasheet and search for "Alarm" to find some explanations.

   

 

   

Bob

urchc_1533771
Level 5
Level 5
5 likes given First like received First like given

My bad English enough to be moderator of programming group with more than 1500 users.

   

https://groups.yahoo.com/neo/groups/skill_school/info

   

And you do not have to answer to all questions even you don`t understand it. 

   

Give opportunity to other members.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

My "translation" advice was not meant to be offending, sorry if you took it wrong.

   

 

   

Bob

0 Likes
urchc_1533771
Level 5
Level 5
5 likes given First like received First like given

Ok. You told about easy way for timer that I can run many times but I need different durations ( 1 min,... 200 min) . What it is ?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

OK, let's evaluate:

   
        
  • What is the clock's precision you need: ms, s, mins or what
  •     
  • What is the clock's accuracy needed
  •     
  • Requirement for deep-sleep to save energy? (will reduce accuracy to 1s)
  •     
  • What is the expected maximum run-time of the clock
  •     
  • Need to store multiple alarms at the same time or will the actual alarm get updated after serving
  •     
  • Need to keep dates, weekdays?
  •     
  • Do you need some of the RTC features as an alarm every day at the same time
  •    
   

Answers to the above specifications will guide you which strategy will be best.

   

Can you tell a bit more about the device you want to build, its functions etc?

   

 

   

Bob