PCA2129 RTC

cancel
Showing results for 
Search instead for 
Did you mean: 

PCA2129 RTC

271 Views
Contributor II

Dear Support,

I have NXP PCA2129 RTC. I want to configure Alarm. I have following questions:

- I want to configure only Hour alarm and want to wake up after every 2 hours.

          * What  (time) should I set in Hour_Alarm register? 

          * Is it simply 2? and then RTC will generate INTERRUPT after 2 hours from the current time?

          * OR Is it read current time and add +2 hours with current time at the event of sleep? It is not clear for me from                   data sheet.

- What is the Year, month, day and time set in factory manufactured RTC out at door?

Amar

Labels (1)
9 Replies

20 Views
NXP TechSupport
NXP TechSupport

Hello Amar,

There is not a sample source for this RTC per se. If you tell me what microcontroller you are using I can check to see if the SDK has an example that may help you.

Best Regards,

Sabina

0 Kudos

20 Views
Contributor II

Hi Sabina,

I am using SPC5643L. Also My question is as follows:

I have set up minute alarm at X min. The alarm happen, sets AF. Now I want to clear AF and also want to clear Alarm Minute Register,

Now AF flag has to be cleared from Control 2 register address 01h and Alarm Minute Register address 0Bh. While clearing should I send address for control 2 register and send AF clear command and then how to clear Alarm Minute Register, Because data sheet says RTC by self increment of register. How to handle this clearing situation?

Do we need to perform in 2 step, first clear AF by sending control 2 address and then in step 2 clear Alarm Minute Register by sending Alarm Minute register address?

How to get this done in 1 step and what address to send? How to get only respective register impacted?

I am able to set alarm and generate AF and then I am able to clear AF as well. However above are few queries.

Thanks

Amar

0 Kudos

20 Views
NXP TechSupport
NXP TechSupport

Hi Amar,

I've checked if there are any example codes for the RTC with the SPC5643L and there is not, I do apologize for the inconvenience this may cause you.

In regards to your question:

 also want to clear Alarm Minute Register

What do you mean clear the Alarm Minute Register?

A) Do you want to disable it, so it no longer produces an alarm at any value?

or 

B) Do you want to reset the alarm minute to a different value?

A) If you want to disable it, you can handle this in the same control register as AF. You may clear AF and AIE at the same time. pastedImage_4.png

pastedImage_5.png

The AIE bit controls if an interrupt is generated or not from all alarm flags (you will disable all other alarm flags such a s hours, seconds, day and weekday).

If you want to disable only the minute alarm flag then it is the AE_M bit. This will be two steps since they are in different addresses. First clear AF then set AE_M to disable.

pastedImage_13.png

pastedImage_14.png

B) If you want to reset the value to something different, you must access the register and write a different value to the minute register. So this will be two steps, first clear the AF then access the minute alarm register to write a new a value. 

If you do not need a new value, but you want the alarm to be triggered again, then you only need to clear AF. Then alarm will be triggered when the clock has the same value in its minute register.

Best Regards,

Sabina

0 Kudos

20 Views
NXP TechSupport
NXP TechSupport

Hello Amar,

To answer your questions:

  * What  (time) should I set in Hour_Alarm register? 

         The number that you set the Hour_Alarm register is the time you'd like the interrupt to occur. So if you put 2, it will interrupt everytime the time is at 2:00:00. 

Is it read current time and add +2 hours with current time at the event of sleep? It is not clear for me from                   data sheet.

This would be the ideal procedure, you would need to read the current time everytime it interrupts, add 2 to the hour and set the hour_alarm register again. 

Another option could also be to use the predefined timers. The timers can be enabled independently from one another by the bits MI(interrupts every minute) and SI(interrupts every second) in register Control_1.  You can read more about this in section 8.12.1 from the datasheet.  If you were to use this you could create an interrupt after 120 minute interrupts that occurr.

Essentially there is not a "right way" to achieve this, you can implement this in different ways.

- What is the Year, month, day and time set in factory manufactured RTC out at door?

As per the datasheet, any register that has a bit marked with an "X" is undefined. This means that there may or may not be a value pre-set, but once you configure this you will set its initial value.

Best Regards, 

Sabina

20 Views
Contributor II

Hi Sabina,

Thank you for your response. I got all my answers. I will come back if I have any more questions.

Thanks

Amar

0 Kudos

20 Views
NXP TechSupport
NXP TechSupport

You're welcome. Do let us know if you have questions in the future.

Best Regards,

Sabina

0 Kudos

20 Views
Contributor II

Hi Sabina,

One quick question, Is there any way to know that RTC is read/ON 1st time? How to recognize that RTC is first time ON and need to configure?

Thanks

Amar

0 Kudos

20 Views
NXP TechSupport
NXP TechSupport

Hello Amar, 

No, there is not any particular flag that states whether it has been read for the first time or not. Essentially once you power it on and configure it, the values will be unchanged with any resets following. If you need to reconfigure it, only then the values should change. 

Remember, as I mentioned before the initial values in the registes are undefined. This means that it is not guaranteed whether the registers have specific 1's or 0's in their bit fields.

Best Regards,

Sabina

20 Views
Contributor II

Hi Sabina,

Do you have sample source code for RTC Alarm? Please share if you have.

Thanks

Amar

0 Kudos