2 years, 8 months ago.

How can I set the alarms, request the alarms and how I notice a Alarm?

I use this library: https://developer.mbed.org/components/DS3231/

I need a exemple Code for set the two alarms in a normal time format, get the two alarms as a printf output and the answer how I notice a triggered alarm?

Thanks for every answer

Question relating to:

Comment on this question

1 Answer

2 years, 8 months ago.

Hello Michael,

Please see the example at the following link

https://developer.mbed.org/users/j3/code/DS3231_Alarm_Demo/file/0cbd468ebbc1/main.cpp

Using the alarms on the DS3231 requires the following:

1. Pull-up on INT/SQW pin of the DS3231 and connecting this pin to a GPIO on your micro. 2. Configuring the DS3231 to use the interrupt pins and which alarm you want to enable 3. Configuring the alarms.

The example above demonstrates the use of Alarm1 to cause an interrupt every 30 seconds and Alarm2 every minute, at the top of the minute.

The structure 'ds3231_alrm_t ' has been provided to allow the user to set the relevant time, day/date information in decimal format and the function 'set_alarm' uses this data to configure the alarm registers, not the control register, which must be configured separately. All members of the structure must be configured with valid values regardless of their use.

The DS3231 alarms are very flexible. Please read the datasheet, page 12, for a description of the alarms and their masking bits.

I hope this helps.

Thanks, Justin