Jump to main content

##

# 2.99.51 RTC_RTCCAlarmSet Function

## C

    bool RTC_RTCCAlarmSet(struct tm *alarmTime, RTC_ALARM_MASK mask)

## Summary

Set an alarm.

## Description

This function allows the application to set the time at which the alarm should occur. The date and time fields to be compared while generating the alarm can also be specified.

## Precondition

RTC_Initialize must have been called for the associated RTC instance. The RTC peripheral should have been configured for Real Time Clock Calendar mode. The RTC_RTCCTimeSet function should have been called to set the current time. Setting this mode will also enable interrupts.

## Parameters

Param | Description
--- | ---
alarmTime | Time structure defines the alarm time.
mask | This enum value defines the date and time fields to be matched at the time of generating alarm. Refer to the description of the RTC_ALARM_MASK enumeration for more details

## Returns

bool.

## Example

    struct tm alarmTime, initialTime;

    RTC_ALARM_MASK mask = RTC_ALARM_MASK_HHMMSS;
    RTC_Initialize();

    // Set the time first to 22:31:23 on 7 April 1980.
    initialTime.tm_sec = 23;
    initialTime.tm_min = 31;
    initialTime.tm_hour = 22;
    initialTime.tm_mday = 7;
    initialTime.tm_mon = 3;
    initialTime.tm_year = 80;

    RTC_RTCCTimeSet(&initialTime);

    // Set the alarm time to 08:00:00.
    alarmTime.tm_sec = 00;
    alarmTime.tm_min = 00;
    alarmTime.tm_hour = 08;

    // The mask is specified to match all time field and ignore all date
    // fields.
    if(RTC_RTCCAlarmSet(&alarmTime, mask) == false)
    {
        //incorrect format
    }

## Remarks

None.