The Designer's Guide Community Forum
General >> Tech Talk >> How to find out a way to deactivate the alarm that is already set please?

Message started by sunrise7747 on Apr 12th, 2018, 2:33am

Title: How to find out a way to deactivate the alarm that is already set please?
Post by sunrise7747 on Apr 12th, 2018, 2:33am

Hi friends, :D
I interfaced DS3231 RTC to Atmega328, the datasheet of DS3231 see

I am not able to find out a way to deactivate the alarm that is already set.
In register 0x0E, AxIE is used to enable/disable the interrupt. INTCN is used to control the interrupt/ square wave.
In register 0x0F, AxF bits indicate whether alarm flag is set or not. We can only clear the flag if it is set.
A1M1 to A1M4 are used to set alarm rate.

So in case I already set alarm and want to cancel, what should be done? Because of this, I do not think I can read the status whether alarm is set or not. I guess we need to have one more register to keep track of enable/disable alarms.

I do not want to use INT/SQW pin (that can be attached to Pin change or external interrupt), but I want to read the A1F/A2F flags periodically in my software and then raise alarm accordingly. I agree that we could always read the time value from the RTC chip and compare in software. But since there is a feature in RTC chip, I thought I can use it.

Assume that I want to go to "alarm set" mode in my system. In that mode, I display the current values of the alarm registers (Hours and Mins) and also the current state of alarm (whether ON or OFF). So to do this, I want to use DS3231 itself and read and display current values instead of making use of locally stored data. Another case if I want to cancel the alarm that may be set accidentally. 

After some tests, I observed that if we do not use interrupt, A1IE/A2IE bit is of no use. These two flags can be set or reset by the application software, but they do not get updated by alarm status flags. A1IE Enable/Disable does not impact the alarm flag. 
datasheet does not talk about default values on start up it looks. So I am clearing A1F/A2F during processor start up. But I am not sure what happens  to A1F/A2F when periodic alarm is enabled using A1M1 to A1M4 bits. I tried once, but found that if we clear, they do not get set again even if repeat option is enabled. Not sure how the behavior is when repeat  is opted.

To conclude: Alarm cannot be disabled in chip once it is written (undo option is not there). Software has to take care of this keeping local enable/disable flag. Right? Any thought?

Thanks in advance and Regards!

The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.