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.

Modules

 

Functions

void rtt_disable_interrupt (Rtt *p_rtt, uint32_t ul_sources)
 Disable RTT interrupts. 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...
 
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...
 

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.

Referenced by rtt_write_alarm_time(), and sw_timer_disable().

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.

Referenced by configure_rtt(), gpbr_test_configure_rtt(), rtt_write_alarm_time(), and sw_timer_enable().

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.

Referenced by configure_rtt(), gpbr_test_configure_rtt(), and sw_timer_init().

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.

Referenced by configure_rtt(), gpbr_test_configure_rtt(), refresh_display(), and sw_timer_init().

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 flag, rtt_disable_interrupt(), and rtt_enable_interrupt().

Referenced by main(), and run_gpbr_test().