Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Real-time Timer (RTT)

The Real-time Timer is built around a 32-bit counter used to count roll-over events of the programmable 16-bit prescaler, which enables counting elapsed seconds from a 32 kHz slow clock source.

This is a driver for configuration and use of the RTT peripheral.

Functions

void rtt_disable (Rtt *p_rtt)
 Disable RTT. More...
 
void rtt_disable_interrupt (Rtt *p_rtt, uint32_t ul_sources)
 Disable RTT interrupts. More...
 
void rtt_enable (Rtt *p_rtt)
 Enable RTT. More...
 
void rtt_enable_interrupt (Rtt *p_rtt, uint32_t ul_sources)
 Enable RTT interrupts. More...
 
uint32_t rtt_get_status (Rtt *p_rtt)
 Get the status register value of the given RTT. More...
 
uint32_t rtt_init (Rtt *p_rtt, uint16_t us_prescaler)
 Initialize the given RTT. More...
 
uint32_t rtt_read_timer_value (Rtt *p_rtt)
 Read the current value of the RTT timer value. More...
 
void rtt_sel_source (Rtt *p_rtt, bool is_rtc_sel)
 Select RTT counter source. More...
 
uint32_t rtt_write_alarm_time (Rtt *p_rtt, uint32_t ul_alarm_time)
 Configure the RTT to generate an alarm at the given time. More...
 

Variables

static uint32_t g_wobits_in_rtt_mr = 0
 

void rtt_disable ( Rtt *  p_rtt)

Disable RTT.

Parameters
p_rttPointer to an RTT instance.

References g_wobits_in_rtt_mr.

void rtt_disable_interrupt ( Rtt *  p_rtt,
uint32_t  ul_sources 
)

Disable RTT interrupts.

Parameters
p_rttPointer to an RTT instance.
ul_sourcesInterrupts to be disabled.

References g_wobits_in_rtt_mr.

Referenced by rtt_write_alarm_time().

void rtt_enable ( Rtt *  p_rtt)

Enable RTT.

Parameters
p_rttPointer to an RTT instance.

References g_wobits_in_rtt_mr.

void rtt_enable_interrupt ( Rtt *  p_rtt,
uint32_t  ul_sources 
)

Enable RTT interrupts.

Parameters
p_rttPointer to an RTT instance.
ul_sourcesInterrupts to be enabled.

References g_wobits_in_rtt_mr.

Referenced by configure_rtt(), and rtt_write_alarm_time().

uint32_t rtt_get_status ( Rtt *  p_rtt)

Get the status register value of the given RTT.

Parameters
p_rttPointer to an RTT instance.
Returns
The Real-time Timer status.

Referenced by RTT_Handler().

uint32_t rtt_init ( Rtt *  p_rtt,
uint16_t  us_prescaler 
)

Initialize the given RTT.

Note
This function restarts the real-time timer. If w_prescaler is equal to zero, the prescaler period is equal to 2^16 * SCLK period. If not, the prescaler period is equal to us_prescaler * SCLK period.
Parameters
p_rttPointer to an RTT instance.
us_prescalerPrescaler value for the RTT.
Returns
0 if successful.

References g_wobits_in_rtt_mr.

Referenced by configure_rtt().

uint32_t rtt_read_timer_value ( Rtt *  p_rtt)

Read the current value of the RTT timer value.

Parameters
p_rttPointer to an RTT instance.
Returns
The current Real-time Timer value.
void rtt_sel_source ( Rtt *  p_rtt,
bool  is_rtc_sel 
)

Select RTT counter source.

Parameters
p_rttPointer to an RTT instance.
is_rtc_selRTC 1Hz Clock Selection.

References g_wobits_in_rtt_mr.

Referenced by configure_rtt().

uint32_t rtt_write_alarm_time ( Rtt *  p_rtt,
uint32_t  ul_alarm_time 
)

Configure the RTT to generate an alarm at the given time.

alarm happens when CRTV value equals ALMV+1, so RTT_AR should be alarmtime - 1. if you want to get alarm when rtt hit 0 , ALMV should be set to 0xFFFFFFFF.

Parameters
p_rttPointer to an RTT instance.
ul_alarm_timeAlarm time,Alarm time = ALMV + 1.
Return values
0Configuration is done.

Alarm time = ALMV + 1,If the incoming parameter is 0, the ALMV is set to 0xFFFFFFFF.

References rtt_disable_interrupt(), and rtt_enable_interrupt().

uint32_t g_wobits_in_rtt_mr = 0
static