TIMER - Timer/Counter#
Introduction#
This module contains functions to control the TIMER peripheral of Silicon Labs' 32-bit MCUs and SoCs. The general purpose timer has 3 or 4 compare/capture channels for input capture and compare/Pulse-Width Modulation (PWM) output. The TIMER module may be 16 or 32 bits wide. Some timers also include a Dead-Time Insertion module suitable for motor control applications.
Refer to the device data sheet to determine the capabilities (capture/compare channel count, width, and DTI) of each timer instance.
Examples#
TIMER enable counter example:
{
// Enable the clock for the timer.
sl_clock_manager_enable_bus_clock(SL_BUS_CLOCK_TIMER0);
// Initialize a timer and enable it.
sl_hal_timer_init_t init = SL_HAL_TIMER_INIT_DEFAULT;
sl_hal_timer_init(TIMER0, &init);
sl_hal_timer_enable(TIMER0);
// Get counter value.
uint32_t counter_value = sl_hal_timer_get_counter(TIMER0);
// Start counter.
sl_hal_timer_start(TIMER0);
// [User code]
// Get a new counter value.
uint32_t new_counter_value = sl_hal_timer_get_counter(TIMER0);
// Stop counter.
sl_hal_timer_stop(TIMER0);
sl_hal_timer_disable(TIMER0);
}
TIMER interrupt example:
// Global irq flag.
static volatile uint32_t irq_flag = 0;
// Example IRQHandler.
void TIMER0_IRQHandler(void)
{
// Get all pending and enabled interrupts.
uint32_t pending = sl_hal_timer_get_enabled_pending_interrupts(TIMER0);
// Handle different IRQ flags here, execute callbacks, etc.
if (pending) {
sl_hal_timer_clear_interrupts(TIMER0, pending);
irq_flag = pending;
}
}
void timer_example(void)
{
// Enable the clock for the timer.
sl_clock_manager_enable_bus_clock(SL_BUS_CLOCK_TIMER0);
// Initialize a timer and enable it.
sl_hal_timer_init_t init = SL_HAL_TIMER_INIT_DEFAULT;
sl_hal_timer_init(TIMER0, &init);
sl_hal_timer_enable(TIMER0);
sl_hal_timer_clear_interrupts(TIMER0, _TIMER_IF_MASK);
sl_hal_timer_enable_interrupts(TIMER0, _TIMER_IEN_MASK);
sl_interrupt_manager_enable_irq(TIMER0_IRQn);
sl_hal_timer_start(TIMER0);
// Wait until we get the flag.
while (!irq_flag) ;
// Cleanup.
sl_hal_timer_stop(TIMER0);
sl_interrupt_manager_disable_irq(TIMER0_IRQn);
sl_hal_timer_reset(TIMER0);
sl_clock_manager_disable_bus_clock(SL_BUS_CLOCK_TIMER0);
}
TIMER buffer update mode example:
void timer_buffer_update_example(void)
{
// Enable the clock for the timer
sl_clock_manager_enable_bus_clock(SL_BUS_CLOCK_TIMER0);
// Initialize timer with update mode enabled
sl_hal_timer_init_t init = SL_HAL_TIMER_INIT_DEFAULT;
init.enable_update_mode = true; // Enable manual update mode
// Initialize a channel for PWM operation
sl_hal_timer_channel_init_t channel_config = SL_HAL_TIMER_CHANNEL_PWM_INIT_DEFAULT;
// Configure timer and channel
sl_hal_timer_init(TIMER0, &init);
sl_hal_timer_channel_init(TIMER0, 0, &channel_config);
// Set initial parameters
sl_hal_timer_set_top(TIMER0, 10000); // Set PWM period
sl_hal_timer_channel_set_compare(TIMER0, 0, 5000); // 50% duty cycle
// Enable timer and start counting
sl_hal_timer_enable(TIMER0);
sl_hal_timer_wait_sync(TIMER0);
sl_hal_timer_start(TIMER0);
// Change PWM parameters using buffer registers
uint32_t new_compare_value = 7500; // New PWM compare value (75% duty cycle)
uint32_t new_phase_value = 1000; // New phase value
uint8_t new_dither_value = 8; // New dither value
// Write to buffer registers (not immediately applied)
sl_hal_timer_channel_set_compare_buffer(TIMER0, 0, new_compare_value);
sl_hal_timer_channel_set_phase_buffer(TIMER0, 0, new_phase_value);
sl_hal_timer_channel_set_dither_buffer(TIMER0, 0, new_dither_value);
// With update_mode enabled, buffer values are only marked for
// transfer after explicitly calling sl_hal_timer_channel_update_registers()
sl_hal_timer_channel_update_registers(TIMER0);
// Check if buffer values are pending transfer
uint32_t status = sl_hal_timer_get_status2(TIMER0);
if ((status & _TIMER_STATUS2_PHASEBV0_MASK) &&
(status & _TIMER_STATUS2_DITHERBV0_MASK)) {
// Buffer values are pending transfer at next overflow/underflow
}
// Optionally force an update event soon by setting counter close to overflow
sl_hal_timer_set_counter(TIMER0, 0xffff0000);
// Wait for synchronization and transfer to complete
sl_hal_timer_wait_sync(TIMER0);
// Verify buffer values have been transferred
status = sl_hal_timer_get_status2(TIMER0);
if (!(status & _TIMER_STATUS2_PHASEBV0_MASK) &&
!(status & _TIMER_STATUS2_DITHERBV0_MASK)) {
// Buffer values have been transferred to active registers
// Read active register values to confirm
uint32_t current_compare = sl_hal_timer_channel_get_compare(TIMER0, 0);
uint32_t current_phase = sl_hal_timer_channel_get_phase(TIMER0, 0);
uint32_t current_dither = sl_hal_timer_channel_get_dither(TIMER0, 0);
}
// Cleanup
sl_hal_timer_stop(TIMER0);
sl_hal_timer_disable(TIMER0);
sl_clock_manager_disable_bus_clock(SL_BUS_CLOCK_TIMER0);
}
Note
When update_mode is disabled (default), buffer values are automatically transferred to active registers at the next update event (overflow/underflow). When update_mode is enabled, sl_hal_timer_channel_update_registers() must be called to mark buffers for transfer at the next update event.
Modules#
Enumerations#
Timer compare/capture mode.
Clock select.
Input capture edge select.
Input capture event control.
Input edge action.
Timer mode.
Compare/capture output action.
Prescaler.
Input type.
DT (Dead Time) Fault Actions.
Functions#
Initialize TIMER.
Initialize the TIMER compare/capture channel.
Initialize the TIMER DTI unit.
Reset the TIMER to the same state that it was in after a hardware reset.
Wait for ongoing sync of register(s) to the low-frequency domain to complete.
Wait for disabling to finish.
Enable TIMER.
Disable TIMER.
Start TIMER.
Stop TIMER.
Get capture value for the capture channel.
Get the buffered capture value for capture channel.
Get compare value for the compare channel.
Get the buffered compare value for compare channel.
Set the compare value buffer for the compare/capture channel when operating in compare or PWM mode.
Set the compare value for compare/capture channel when operating in compare or PWM mode.
Get the TIMER counter value.
Set the TIMER counter value.
Set the top value buffer for the timer.
Set the top value for timer.
Get the top value setting for the timer.
Get status values for the timer.
Lock some TIMER registers to protect them from being modified.
Unlock some TIMER registers to be able to modify registers.
Enable DTI unit.
Disable DTI unit.
Get DTI fault source flags status.
Clear DTI fault source flags.
Unlock timer DTI to enable writing to locked registers again.
Lock timer DTI to disable writing to registers.
Clear one or more pending TIMER interrupts.
Disable one or more TIMER interrupts.
Enable one or more TIMER interrupts.
Get pending TIMER interrupt flags.
Get enabled and pending TIMER interrupt flags.
Set one or more pending TIMER interrupts from SW.
Macros#
Check if TIMER instance is valid.
Return TIMER instance max count.
Return TIMER instance channel count.
Check if TIMER instance supports DTI.
Default configuration for TIMER initialization structure.
Default configuration for TIMER compare/capture initialization structure.
PWM mode configuration for TIMER compare/capture initialization structure.
Default configuration for TIMER DTI initialization structure. TODO CM SL_HAL_TIMER_DTI_CONFIG_DEFAULT incorrect.
Enumeration Documentation#
sl_hal_timer_channel_mode_t#
sl_hal_timer_channel_mode_t
Timer compare/capture mode.
Enumerator | |
---|---|
SL_HAL_TIMER_CHANNEL_MODE_OFF | Channel turned off. |
SL_HAL_TIMER_CHANNEL_MODE_CAPTURE | Input capture. |
SL_HAL_TIMER_CHANNEL_MODE_COMPARE | Output compare. |
SL_HAL_TIMER_CHANNEL_MODE_PWM | Pulse-Width modulation. |
sl_hal_timer_clock_select_t#
sl_hal_timer_clock_select_t
Clock select.
Enumerator | |
---|---|
SL_HAL_TIMER_CLKSEL_HFPERCLK | Prescaled EM01GRPA clock. |
SL_HAL_TIMER_CLKSEL_CC1 | Compare/Capture Channel 1 Input. |
SL_HAL_TIMER_CLKSEL_CASCADE | Cascaded clocked by underflow or overflow by lower numbered timer. |
sl_hal_timer_channel_input_edge_t#
sl_hal_timer_channel_input_edge_t
Input capture edge select.
Enumerator | |
---|---|
SL_HAL_TIMER_CHANNEL_EDGE_RISING | Rising edges detected. |
SL_HAL_TIMER_CHANNEL_EDGE_FALLING | Falling edges detected. |
SL_HAL_TIMER_CHANNEL_EDGE_BOTH | Both edges detected. |
SL_HAL_TIMER_CHANNEL_EDGE_NONE | No edge detection, leave signal as is. |
sl_hal_timer_channel_input_event_t#
sl_hal_timer_channel_input_event_t
Input capture event control.
Enumerator | |
---|---|
SL_HAL_TIMER_CHANNEL_EVENT_EVERY_EDGE | PRS output pulse, interrupt flag, and DMA request set on every capture. |
SL_HAL_TIMER_CHANNEL_EVENT_EVERY_SECONDE_EDGE | PRS output pulse, interrupt flag, and DMA request set on every second capture. |
SL_HAL_TIMER_CHANNEL_EVENT_RISING | PRS output pulse, interrupt flag, and DMA request set on rising edge (if input capture edge = BOTH). |
SL_HAL_TIMER_CHANNEL_EVENT_FALLING | PRS output pulse, interrupt flag, and DMA request set on falling edge (if input capture edge = BOTH). |
sl_hal_timer_input_edge_action_t#
sl_hal_timer_input_edge_action_t
Input edge action.
Enumerator | |
---|---|
SL_HAL_TIMER_INPUT_ACTION_NONE | No action taken. |
SL_HAL_TIMER_INPUT_ACTION_START | Start counter without reload. |
SL_HAL_TIMER_INPUT_ACTION_STOP | Stop counter without reload. |
SL_HAL_TIMER_INPUT_ACTION_RELOAD_START | Reload and start counter. |
sl_hal_timer_mode_t#
sl_hal_timer_mode_t
Timer mode.
Enumerator | |
---|---|
SL_HAL_TIMER_MODE_UP | Up-counting. |
SL_HAL_TIMER_MODE_DOWN | Down-counting. |
SL_HAL_TIMER_MODE_UPDOWN | Up/down-counting. |
SL_HAL_TIMER_MODE_QDEC | Quadrature decoder. |
sl_hal_timer_channel_output_action_t#
sl_hal_timer_channel_output_action_t
Compare/capture output action.
Enumerator | |
---|---|
SL_HAL_TIMER_CHANNEL_OUTPUT_ACTION_NONE | No action. |
SL_HAL_TIMER_CHANNEL_OUTPUT_ACTION_TOGGLE | Toggle on event. |
SL_HAL_TIMER_CHANNEL_OUTPUT_ACTION_CLEAR | Clear on event. |
SL_HAL_TIMER_CHANNEL_OUTPUT_ACTION_SET | Set on event. |
sl_hal_timer_prescaler_t#
sl_hal_timer_prescaler_t
Prescaler.
Enumerator | |
---|---|
SL_HAL_TIMER_PRESCALER_DIV1 | Divide by 1. |
SL_HAL_TIMER_PRESCALER_DIV2 | Divide by 2. |
SL_HAL_TIMER_PRESCALER_DIV4 | Divide by 4. |
SL_HAL_TIMER_PRESCALER_DIV8 | Divide by 8. |
SL_HAL_TIMER_PRESCALER_DIV16 | Divide by 16. |
SL_HAL_TIMER_PRESCALER_DIV32 | Divide by 32. |
SL_HAL_TIMER_PRESCALER_DIV64 | Divide by 64. |
SL_HAL_TIMER_PRESCALER_DIV128 | Divide by 128. |
SL_HAL_TIMER_PRESCALER_DIV256 | Divide by 256. |
SL_HAL_TIMER_PRESCALER_DIV512 | Divide by 512. |
SL_HAL_TIMER_PRESCALER_DIV1024 | Divide by 1024. |
sl_hal_timer_channel_input_type_t#
sl_hal_timer_channel_input_type_t
Input type.
Enumerator | |
---|---|
SL_HAL_TIMER_CHANNEL_INPUT_PIN | No PRS input. |
SL_HAL_TIMER_CHANNEL_INPUT_PRS_SYNC | Synchronous PRS selected. |
SL_HAL_TIMER_CHANNEL_INPUT_PRS_ASYNC_LEVEL | Asynchronous level PRS selected. |
SL_HAL_TIMER_CHANNEL_INPUT_PRS_ASYNC_PULSE | Asynchronous pulse PRS selected. |
sl_hal_timer_dti_fault_action_t#
sl_hal_timer_dti_fault_action_t
DT (Dead Time) Fault Actions.
Enumerator | |
---|---|
SL_HAL_TIMER_DTI_FAULT_ACTION_NONE | No action on fault. |
SL_HAL_TIMER_DTI_FAULT_ACTION_INACTIVE | Set outputs inactive. |
SL_HAL_TIMER_DTI_FAULT_ACTION_CLEAR | Clear outputs. |
SL_HAL_TIMER_DTI_FAULT_ACTION_TRISTATE | Tristate outputs. |
Function Documentation#
sl_hal_timer_init#
void sl_hal_timer_init (TIMER_TypeDef * timer, const sl_hal_timer_init_t * init)
Initialize TIMER.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | A pointer to the TIMER peripheral register block. |
const sl_hal_timer_init_t * | [in] | init | A pointer to the TIMER initialization structure used to configure TIMER. |
Notice that the counter top must be configured separately with, for instance sl_hal_timer_set_top(). In addition, compare/capture and dead-time insertion initialization must be initialized separately if used, which should probably be done prior to using this function if configuring the TIMER to start when initialization is completed.
sl_hal_timer_channel_init#
void sl_hal_timer_channel_init (TIMER_TypeDef * timer, uint8_t channel, const sl_hal_timer_channel_init_t * init)
Initialize the TIMER compare/capture channel.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | A pointer to the TIMER peripheral register block. |
uint8_t | [in] | channel | A compare/capture channel to initialize for. |
const sl_hal_timer_channel_init_t * | [in] | init | A pointer to the TIMER initialization structure. |
Notice that if operating the channel in compare mode, the OC and OCB register must be set separately, as required.
sl_hal_timer_dti_init#
void sl_hal_timer_dti_init (TIMER_TypeDef * timer, const sl_hal_timer_dti_init_t * init)
Initialize the TIMER DTI unit.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | A pointer to the TIMER peripheral register block. |
const sl_hal_timer_dti_init_t * | [in] | init | A pointer to the TIMER DTI initialization structure. |
sl_hal_timer_reset#
void sl_hal_timer_reset (TIMER_TypeDef * timer)
Reset the TIMER to the same state that it was in after a hardware reset.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | A pointer to the TIMER peripheral register block. |
Note
The ROUTE register is NOT reset by this function to allow for a centralized setup of this feature.
sl_hal_timer_wait_sync#
void sl_hal_timer_wait_sync (TIMER_TypeDef * timer)
Wait for ongoing sync of register(s) to the low-frequency domain to complete.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the timer peripheral register block. |
sl_hal_timer_wait_ready#
void sl_hal_timer_wait_ready (TIMER_TypeDef * timer)
Wait for disabling to finish.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
sl_hal_timer_enable#
void sl_hal_timer_enable (TIMER_TypeDef * timer)
Enable TIMER.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
sl_hal_timer_disable#
void sl_hal_timer_disable (TIMER_TypeDef * timer)
Disable TIMER.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
sl_hal_timer_start#
void sl_hal_timer_start (TIMER_TypeDef * timer)
Start TIMER.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
sl_hal_timer_stop#
void sl_hal_timer_stop (TIMER_TypeDef * timer)
Stop TIMER.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
sl_hal_timer_channel_get_capture#
uint32_t sl_hal_timer_channel_get_capture (TIMER_TypeDef * timer, uint8_t channel)
Get capture value for the capture channel.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
uint8_t | [in] | channel | Capture channel to access. |
Returns
Current capture value.
sl_hal_timer_channel_get_capture_buffer#
uint32_t sl_hal_timer_channel_get_capture_buffer (TIMER_TypeDef * timer, uint8_t channel)
Get the buffered capture value for capture channel.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
uint8_t | [in] | channel | Capture channel to access. |
Returns
Current buffered capture value.
sl_hal_timer_channel_get_compare#
uint32_t sl_hal_timer_channel_get_compare (TIMER_TypeDef * timer, uint8_t channel)
Get compare value for the compare channel.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
uint8_t | [in] | channel | Compare channel to access. |
Returns
Current compare value.
sl_hal_timer_channel_get_compare_buffer#
uint32_t sl_hal_timer_channel_get_compare_buffer (TIMER_TypeDef * timer, uint8_t channel)
Get the buffered compare value for compare channel.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
uint8_t | [in] | channel | Compare channel to access. |
Returns
Current buffered compare value.
sl_hal_timer_channel_set_compare_buffer#
void sl_hal_timer_channel_set_compare_buffer (TIMER_TypeDef * timer, uint8_t channel, uint32_t value)
Set the compare value buffer for the compare/capture channel when operating in compare or PWM mode.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
uint8_t | [in] | channel | Compare/capture channel to access. |
uint32_t | [in] | value | Value to set in compare value buffer register. |
The compare value buffer holds the value which will be written to TIMERn_CCx_CCV on an update event if the buffer has been updated since the last event.
sl_hal_timer_channel_set_compare#
void sl_hal_timer_channel_set_compare (TIMER_TypeDef * timer, uint8_t channel, uint32_t value)
Set the compare value for compare/capture channel when operating in compare or PWM mode.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
uint8_t | [in] | channel | Compare/capture channel to access. |
uint32_t | [in] | value | Value to set in compare value register. |
sl_hal_timer_get_counter#
uint32_t sl_hal_timer_get_counter (TIMER_TypeDef * timer)
Get the TIMER counter value.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to TIMER peripheral register block. |
Returns
Current TIMER counter value.
sl_hal_timer_set_counter#
void sl_hal_timer_set_counter (TIMER_TypeDef * timer, uint32_t value)
Set the TIMER counter value.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
uint32_t | [in] | value | Value to set counter to. |
sl_hal_timer_set_top_buffer#
void sl_hal_timer_set_top_buffer (TIMER_TypeDef * timer, uint32_t value)
Set the top value buffer for the timer.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
uint32_t | [in] | value | Value to set in top value buffer register. |
When top value buffer register is updated, value is loaded into top value register at the next wrap around. This feature is useful in order to update top value safely when timer is running.
sl_hal_timer_set_top#
void sl_hal_timer_set_top (TIMER_TypeDef * timer, uint32_t value)
Set the top value for timer.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
uint32_t | [in] | value | Value to set in top value register. |
sl_hal_timer_get_top#
uint32_t sl_hal_timer_get_top (TIMER_TypeDef * timer)
Get the top value setting for the timer.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
Returns
Current top value.
sl_hal_timer_get_status#
uint32_t sl_hal_timer_get_status (TIMER_TypeDef * timer)
Get status values for the timer.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
Returns
Current status values.
sl_hal_timer_lock#
void sl_hal_timer_lock (TIMER_TypeDef * timer)
Lock some TIMER registers to protect them from being modified.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to TIMER peripheral register block. |
Refer to the reference manual for TIMER registers that will be locked.
Note
If locking the TIMER registers, they must be unlocked prior to using any TIMER API function that modifies TIMER registers protected by the lock.
sl_hal_timer_unlock#
void sl_hal_timer_unlock (TIMER_TypeDef * timer)
Unlock some TIMER registers to be able to modify registers.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to TIMER peripheral register block. |
Refer to the reference manual for TIMER registers that will be unlocked.
Note
Unlock prior to using any TIMER API function that modifies TIMER registers protected by the lock.
sl_hal_timer_dti_enable#
void sl_hal_timer_dti_enable (TIMER_TypeDef * timer)
Enable DTI unit.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
Make sure to enable the DTI before enabling the timer.
sl_hal_timer_dti_disable#
void sl_hal_timer_dti_disable (TIMER_TypeDef * timer)
Disable DTI unit.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
Make sure to disable the DTI before enabling the timer.
sl_hal_timer_dti_get_fault#
uint32_t sl_hal_timer_dti_get_fault (TIMER_TypeDef * timer)
Get DTI fault source flags status.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
Note
Event bits are not cleared by this function.
Returns
Status of the DTI fault source flags. Returns one or more valid DTI fault source flags (TIMER_DTFAULT_nnn) OR'ed together.
sl_hal_timer_dti_clear_fault#
void sl_hal_timer_dti_clear_fault (TIMER_TypeDef * timer, uint32_t flags)
Clear DTI fault source flags.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
uint32_t | [in] | flags | DTI fault source(s) to clear. Use one or more valid DTI fault source flags (TIMER_DTFAULT_nnn) OR'ed together. |
sl_hal_timer_dti_unlock#
void sl_hal_timer_dti_unlock (TIMER_TypeDef * timer)
Unlock timer DTI to enable writing to locked registers again.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
sl_hal_timer_dti_lock#
void sl_hal_timer_dti_lock (TIMER_TypeDef * timer)
Lock timer DTI to disable writing to registers.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
sl_hal_timer_clear_interrupts#
void sl_hal_timer_clear_interrupts (TIMER_TypeDef * timer, uint32_t flags)
Clear one or more pending TIMER interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
uint32_t | [in] | flags | Pending TIMER interrupt source(s) to clear. Use one or more valid interrupt flags for the TIMER module (TIMER_IF_nnn) OR'ed together. |
sl_hal_timer_disable_interrupts#
void sl_hal_timer_disable_interrupts (TIMER_TypeDef * timer, uint32_t flags)
Disable one or more TIMER interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
uint32_t | [in] | flags | TIMER interrupt source(s) to disable. Use one or more valid interrupt flags for the TIMER module (TIMER_IF_nnn) OR'ed together. |
sl_hal_timer_enable_interrupts#
void sl_hal_timer_enable_interrupts (TIMER_TypeDef * timer, uint32_t flags)
Enable one or more TIMER interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
uint32_t | [in] | flags | TIMER interrupt source(s) to enable. Use one or more valid interrupt flags for the TIMER module (TIMER_IF_nnn) OR'ed together. |
Note
Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. To ignore a pending interrupt, consider using TIMER_IntClear() prior to enabling the interrupt.
sl_hal_timer_get_pending_interrupts#
uint32_t sl_hal_timer_get_pending_interrupts (TIMER_TypeDef * timer)
Get pending TIMER interrupt flags.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
Note
Event bits are not cleared by this function.
Returns
TIMER interrupt source(s) pending. Returns one or more valid interrupt flags for the TIMER module (TIMER_IF_nnn) OR'ed together.
sl_hal_timer_get_enabled_pending_interrupts#
uint32_t sl_hal_timer_get_enabled_pending_interrupts (TIMER_TypeDef * timer)
Get enabled and pending TIMER interrupt flags.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
Useful for handling more interrupt sources in the same interrupt handler.
Note
Interrupt flags are not cleared by this function.
Returns
Pending and enabled TIMER interrupt sources. The return value is the bitwise AND combination of
the OR combination of enabled interrupt sources in TIMERx_IEN_nnn register (TIMERx_IEN_nnn) and
the OR combination of valid interrupt flags of the TIMER module (TIMERx_IF_nnn).
sl_hal_timer_set_interrupts#
void sl_hal_timer_set_interrupts (TIMER_TypeDef * timer, uint32_t flags)
Set one or more pending TIMER interrupts from SW.
Type | Direction | Argument Name | Description |
---|---|---|---|
TIMER_TypeDef * | [in] | timer | Pointer to the TIMER peripheral register block. |
uint32_t | [in] | flags | TIMER interrupt source(s) to set to pending. Use one or more valid interrupt flags for the TIMER module (TIMER_IF_nnn) OR'ed together. |