1.33.15.28 RTC_Timer16PeriodSet Function

C

void RTC_Timer16PeriodSet ( uint16_t period )

Summary

Set the 16-bit timer period value.

Description

This function sets the 16-bit timer period value. The counter value will be compared against the period value and a period expiry event will occur when the counter matches the period. If the library is configured for interrupt mode and if a event handler function has been set through the RTC_Timer16CallbackRegister() function, the event handling function will be called. Additionally the RTC_Timer16CounterHasOverflowed() function will return true. When the match occurs, the counter will be reset and the counting will start again.

Setting the period to a non-zero value will cause the timer counter to operate as a timer that counts up to a specific value and resets. Setting the period to 0 will cause the timer counter to operate as counter, using the full range of the 16-bit timer, that can be used to measure a time duration.

Precondition

RTC_Initialize must have been called for the associated RTC instance. The RTC peripheral should have been configured in 16-bit Timer Counter mode.

Parameters

Param Description
period timer period value

Returns

None.

Example

uint16_t period = 0x0FFF;
RTC_Initialize();
RTC_Timer16PeriodSet(period);
RTC_Timer16CounterSet(0);
RTC_Timer16Start();
while(!RTC_Timer16CounterHasOverflowed());

Remarks

The RTC_Timer16Start() should typically be called after the period has been set.