3.14.4 16-bit Timer/Counter A with PWM
16-bit Timer/Counter type A (TCA) with three compare channels for PWM and waveform generation.
3.14.4.1 Introduction
The Timer/Counter type A (TCA) is a 16-bit flexible timer that can perform complex actions as well as the basic functions of a simple timer. The TCA can be split into two completely independent 8-bit timers and can also support Wave Generation modes. Another important characteristic is that the TCA was devised to overcome common problems when using timers, such as the unpredictable behavior of the Pulse-Width Modulator (PWM) signal when the duty cycle is changed while the timer is running. The TCA has double-buffered registers that synchronize the updates of different registers, making the generated waveforms predictable in every single situation.
3.14.4.2 Supported Device Families
AVR® Dx | AVR® Ex | ATtiny | ATmega |
3.14.4.3 Required Header Files
#include "mcc_generated_files/timer/tca[X].h"
3.14.4.4 How to use the TCA PLIB
Click the links to view the code snippets associated with each example:
- TCA Use Case 1: Timer Period Change in Non-Interrupt Mode This example demonstrates an application where the timer period changes from 4 ms to 8 ms and vice versa with every overflow of the timer.
- TCA Use Case 2: LED Toggle using Interrupts This example toggles an LED when an period match interrupt event occurs.
- TCA Use Case 3: Timer Wake from Sleep at Interrupt event This example wakes the microcontroller from Sleep mode every five seconds.
- TCA Use Case 4: 250 Hz Output Signal on GPIO PinThis example configures the TCA PLIB to generate a signal of a specified frequency on a pin.
- TCA Use Case 5: Variable Duty Cycle PWM generation using TCA Split ModeThis example configures the TCA PLIB in Split mode to generate 10 ms/5 ms PWM signals with various duty cycles on the selected waveform output pins
3.14.4.5 Specific MISRA C:2012 Deviations
- Global TCA0_MAX_COUNT
-
Advisory: misra-c2012-2.5
Justification: MCC Melody drivers provide macros that can be added to an application. It depends on the application whether a macro is used or not.Advisory: misra-c2012-2.5
Justification: MCC Melody drivers provide macros that can be added to an application. It depends on the application whether a macro is used or not. - Global TCA0_Read
-
Advisory: misra-c2012-2.5
Justification: MCC Melody drivers provide macros that can be added to an application. It depends on the application whether a macro is used or not. - Global TCA0_ReadHighCount
-
Advisory: misra-c2012-2.5
Justification: MCC Melody drivers provide macros that can be added to an application. It depends on the application whether a macro is used or not.
3.14.4.6 Module Documentation
3.14.4.6.1 TCA0 in Normal Mode
This file contains the API prototypes for the TCA0 driver in Normal (16-bit) mode.
Module description
This file contains the API prototypes for the TCA0 driver in Normal (16-bit) mode.
Typedefs
typedef void(* TCA0_cb_t) (void)
Function pointer to the callback function called by TCA while operating in Normal mode. The default value is set to NULL, which means that no callback function will be used.
Definitions
#define TCA0_MAX_COUNT (65535U)
Defines the maximum count of the timer.
#define TCA0_CLOCK_FREQ (4000000UL)
Defines the timer prescaled clock frequency in hertz.
#define TCA0_Read TCA0_CounterGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_Read will be deprecated in the future release. Use TCA0_CounterGet instead.
#define TCA0_Write TCA0_PeriodSet
Defines the Custom Name for the TCA0_PeriodSet API. The TCA0_Write will be deprecated in the future release. Use TCA0_PeriodSet instead.
#define TCA0_ClearOverflowInterruptFlag TCA0_OverflowStatusClear
Defines the Custom Name for the TCA0_OverflowStatusClear API. The TCA0_ClearOverflowInterruptFlag will be deprecated in the future release. Use TCA0_OverflowStatusClear instead.
#define TCA0_IsOverflowInterruptFlagSet TCA0_OverflowStatusGet
Defines the Custom Name for the TCA0_OverflowStatusGet API. The TCA0_IsOverflowInterruptFlagSet will be deprecated in the future release. Use TCA0_OverflowStatusGet instead.
#define TCA0_ClearCMP0InterruptFlag TCA0_CMP0MatchStatusClear
Defines the Custom Name for the TCA0_CMP0MatchStatusClear API. The TCA0_ClearCMP0InterruptFlag will be deprecated in the future release. Use TCA0_CMP0MatchStatusClear instead.
#define TCA0_IsCMP0InterruptFlagSet TCA0_CMP0MatchStatusGet
Defines the Custom Name for the TCA0_CMP0MatchStatusGet API. The TCA0_IsCMP0InterruptFlagSet will be deprecated in the future release. Use TCA0_CMP0MatchStatusGet instead.
#define TCA0_ClearCMP1InterruptFlag TCA0_CMP1MatchStatusClear
Defines the Custom Name for the TCA0_CMP1MatchStatusClear API. The TCA0_ClearCMP1InterruptFlag will be deprecated in the future release. Use TCA0_CMP1MatchStatusClear instead.
#define TCA0_IsCMP1InterruptFlagSet TCA0_CMP1MatchStatusGet
Defines the Custom Name for the TCA0_CMP1MatchStatusGet API. The TCA0_IsCMP1InterruptFlagSet will be deprecated in the future release. Use TCA0_CMP1MatchStatusGet instead.
#define TCA0_ClearCMP2InterruptFlag TCA0_CMP2MatchStatusClear
Defines the Custom Name for the TCA0_CMP2MatchStatusClear API. The TCA0_ClearCMP2InterruptFlag will be deprecated in the future release. Use TCA0_CMP2MatchStatusClear instead.
#define TCA0_IsCMP2InterruptFlagSet TCA0_CMP2MatchStatusGet
Defines the Custom Name for the TCA0_CMP2MatchStatusGet API. The TCA0_IsCMP2InterruptFlagSet will be deprecated in the future release. Use TCA0_CMP2MatchStatusGet instead.
#define TCA0_WaveformFreqRegCountSet TCA0_FrequencySet
Defines the Custom Name for the TCA0_FrequencySet API. The TCA0_WaveformFreqRegCountSet will be deprecated in the future release. Use TCA0_FrequencySet instead.
#define TCA0_WaveformFreqRegCountGet TCA0_FrequencyGet
Defines the Custom Name for the TCA0_FrequencyGet API. The TCA0_WaveformFreqRegCountGet will be deprecated in the future release. Use TCA0_FrequencyGet instead.
#define TCA0_WO1OffsetRegCountSet TCA0_WO1OffsetSet
Defines the Custom Name for the TCA0_WO1OffsetSet API. The TCA0_WO1OffsetRegCountSet will be deprecated in the future release. Use TCA0_WO1OffsetSet instead.
#define TCA0_WO1OffsetRegCountGet TCA0_WO1OffsetGet
Defines the Custom Name for the TCA0_WO1OffsetGet API. The TCA0_WO1OffsetRegCountGet will be deprecated in the future release. Use TCA0_WO1OffsetGet instead.
#define TCA0_WO2OffsetRegCountSet TCA0_WO2OffsetSet
Defines the Custom Name for the TCA0_WO2OffsetSet API. The TCA0_WO2OffsetRegCountSet will be deprecated in the future release. Use TCA0_WO2OffsetSet instead.
#define TCA0_WO2OffsetRegCountGet TCA0_WO2OffsetGet
Defines the Custom Name for the TCA0_WO2OffsetGet API. The TCA0_WO2OffsetRegCountGet will be deprecated in the future release. Use TCA0_WO2OffsetGet instead.
#define TCA0CounterGet TCA0_CounterGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0CounterGet will be deprecated in the future release. Use TCA0_CounterGet instead.
#define TCA0CounterSet TCA0_CounterSet
Defines the Custom Name for the TCA0_CounterSet API. The TCA0CounterSet will be deprecated in the future release. Use TCA0_CounterSet instead.
Functions
void TCA0_Initialize (void)
Initializes the TCA0 module.
void TCA0_Deinitialize (void)
Deinitializes the TCA0 module.
void TCA0_Start (void)
Starts the TCA0.
void TCA0_Stop (void)
Stops the TCA0.
uint16_t TCA0_CounterGet (void)
Returns the current counter value.
void TCA0_CounterSet (uint16_t count)
Sets the counter value.
uint16_t TCA0_PeriodGet (void)
Returns the current period value.
void TCA0_PeriodSet (uint16_t periodVal)
Sets the period value.
void TCA0_Compare0Set (uint16_t value)
Sets the Compare 0 (CMP0) count value.
void TCA0_Compare1Set (uint16_t value)
Sets the Compare 1 (CMP1) count value.
void TCA0_Compare2Set (uint16_t value)
Sets the Compare 2 (CMP2) count value.
uint16_t TCA0_MaxCountGet (void)
Returns the maximum count value.
void TCA0_FrequencySet (uint16_t count)
Sets the frequency count value.
uint16_t TCA0_FrequencyGet (void)
Returns the frequency count value.
void TCA0_WO1OffsetSet (uint16_t count)
Sets the WO1 offset count value.
uint16_t TCA0_WO1OffsetGet (void)
Returns the WO1 offset count value.
void TCA0_WO2OffsetSet (uint16_t count)
Sets the WO2 offset count value.
uint16_t TCA0_WO2OffsetGet (void)
Returns the WO2 offset count value.
void TCA0_ModeSet (TCA_SINGLE_WGMODE_t mode)
Sets the Waveform Generation mode.
void TCA0_OverflowStatusClear (void)
Clears the TCA0 Overflow Interrupt flag.
bool TCA0_OverflowStatusGet (void)
Returns the status of the TCA0 Overflow Interrupt flag.
void TCA0_CMP0MatchStatusClear (void)
Clears the TCA0 Compare 0 Interrupt flag.
bool TCA0_CMP0MatchStatusGet (void)
Returns the status of the TCA0 Compare 0 Interrupt flag.
void TCA0_CMP1MatchStatusClear (void)
Clears the TCA0 Compare 1 Interrupt flag.
bool TCA0_CMP1MatchStatusGet (void)
Returns the status of the TCA0 Compare 1 Interrupt flag.
void TCA0_CMP2MatchStatusClear (void)
Clears the TCA0 Compare 2 Interrupt flag.
bool TCA0_CMP2MatchStatusGet (void)
Returns the status of the TCA0 Compare 2 Interrupt flag.
void TCA0_InterruptEnable (void)
Enables the TCA0 interrupts.
void TCA0_InterruptDisable (void)
Disables the TCA0 interrupts.
void TCA0_OverflowCallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the TCA0 overflow or underflow event.
void TCA0_Compare0CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the TCA0 Compare 0 match event.
void TCA0_Compare1CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the TCA0 Compare 1 match event.
void TCA0_Compare2CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the TCA0 Compare 2 match event.
void TCA0_Tasks (void)
Performs tasks to be executed during the TCA0 interrupt events.
Definition Documentation
TCA0_ClearCMP0InterruptFlag
#define TCA0_ClearCMP0InterruptFlag TCA0_CMP0MatchStatusClear
Defines the Custom Name for the TCA0_CMP0MatchStatusClear API. The TCA0_ClearCMP0InterruptFlag will be deprecated in the future release. Use TCA0_CMP0MatchStatusClear instead.
TCA0_ClearCMP1InterruptFlag
#define TCA0_ClearCMP1InterruptFlag TCA0_CMP1MatchStatusClear
Defines the Custom Name for the TCA0_CMP1MatchStatusClear API. The TCA0_ClearCMP1InterruptFlag will be deprecated in the future release. Use TCA0_CMP1MatchStatusClear instead.
TCA0_ClearCMP2InterruptFlag
#define TCA0_ClearCMP2InterruptFlag TCA0_CMP2MatchStatusClear
Defines the Custom Name for the TCA0_CMP2MatchStatusClear API. The TCA0_ClearCMP2InterruptFlag will be deprecated in the future release. Use TCA0_CMP2MatchStatusClear instead.
TCA0_ClearOverflowInterruptFlag
#define TCA0_ClearOverflowInterruptFlag TCA0_OverflowStatusClear
Defines the Custom Name for the TCA0_OverflowStatusClear API. The TCA0_ClearOverflowInterruptFlag will be deprecated in the future release. Use TCA0_OverflowStatusClear instead.
TCA0_CLOCK_FREQ
#define TCA0_CLOCK_FREQ (4000000UL)
Defines the timer prescaled clock frequency in hertz.
TCA0_IsCMP0InterruptFlagSet
#define TCA0_IsCMP0InterruptFlagSet TCA0_CMP0MatchStatusGet
Defines the Custom Name for the TCA0_CMP0MatchStatusGet API. The TCA0_IsCMP0InterruptFlagSet will be deprecated in the future release. Use TCA0_CMP0MatchStatusGet instead.
TCA0_IsCMP1InterruptFlagSet
#define TCA0_IsCMP1InterruptFlagSet TCA0_CMP1MatchStatusGet
Defines the Custom Name for the TCA0_CMP1MatchStatusGet API. The TCA0_IsCMP1InterruptFlagSet will be deprecated in the future release. Use TCA0_CMP1MatchStatusGet instead.
TCA0_IsCMP2InterruptFlagSet
#define TCA0_IsCMP2InterruptFlagSet TCA0_CMP2MatchStatusGet
Defines the Custom Name for the TCA0_CMP2MatchStatusGet API. The TCA0_IsCMP2InterruptFlagSet will be deprecated in the future release. Use TCA0_CMP2MatchStatusGet instead.
TCA0_IsOverflowInterruptFlagSet
#define TCA0_IsOverflowInterruptFlagSet TCA0_OverflowStatusGet
Defines the Custom Name for the TCA0_OverflowStatusGet API. The TCA0_IsOverflowInterruptFlagSet will be deprecated in the future release. Use TCA0_OverflowStatusGet instead.
TCA0_MAX_COUNT
#define TCA0_MAX_COUNT (65535U)
Defines the maximum count of the timer.
MISRA C:2012 Deviation Advisory: misra-c2012-2.5
Justification: MCC Melody drivers provide macros that can be added to an application. It depends on the application whether a macro is used or not.TCA0_Read
#define TCA0_Read TCA0_CounterGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_Read will be deprecated in the future release. Use TCA0_CounterGet instead.
MISRA C:2012 Deviation Advisory: misra-c2012-2.5
Justification: MCC Melody drivers provide macros that can be added to an application. It depends on the application whether a macro is used or not.TCA0_WaveformFreqRegCountGet
#define TCA0_WaveformFreqRegCountGet TCA0_FrequencyGet
Defines the Custom Name for the TCA0_FrequencyGet API. The TCA0_WaveformFreqRegCountGet will be deprecated in the future release. Use TCA0_FrequencyGet instead.
TCA0_WaveformFreqRegCountSet
#define TCA0_WaveformFreqRegCountSet TCA0_FrequencySet
Defines the Custom Name for the TCA0_FrequencySet API. The TCA0_WaveformFreqRegCountSet will be deprecated in the future release. Use TCA0_FrequencySet instead.
TCA0_WO1OffsetRegCountGet
#define TCA0_WO1OffsetRegCountGet TCA0_WO1OffsetGet
Defines the Custom Name for the TCA0_WO1OffsetGet API. The TCA0_WO1OffsetRegCountGet will be deprecated in the future release. Use TCA0_WO1OffsetGet instead.
TCA0_WO1OffsetRegCountSet
#define TCA0_WO1OffsetRegCountSet TCA0_WO1OffsetSet
Defines the Custom Name for the TCA0_WO1OffsetSet API. The TCA0_WO1OffsetRegCountSet will be deprecated in the future release. Use TCA0_WO1OffsetSet instead.
TCA0_WO2OffsetRegCountGet
#define TCA0_WO2OffsetRegCountGet TCA0_WO2OffsetGet
Defines the Custom Name for the TCA0_WO2OffsetGet API. The TCA0_WO2OffsetRegCountGet will be deprecated in the future release. Use TCA0_WO2OffsetGet instead.
TCA0_WO2OffsetRegCountSet
#define TCA0_WO2OffsetRegCountSet TCA0_WO2OffsetSet
Defines the Custom Name for the TCA0_WO2OffsetSet API. The TCA0_WO2OffsetRegCountSet will be deprecated in the future release. Use TCA0_WO2OffsetSet instead.
TCA0_Write
#define TCA0_Write TCA0_PeriodSet
Defines the Custom Name for the TCA0_PeriodSet API. The TCA0_Write will be deprecated in the future release. Use TCA0_PeriodSet instead.
TCA0CounterGet
#define TCA0CounterGet TCA0_CounterGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0CounterGet will be deprecated in the future release. Use TCA0_CounterGet instead.
TCA0CounterSet
#define TCA0CounterSet TCA0_CounterSet
Defines the Custom Name for the TCA0_CounterSet API. The TCA0CounterSet will be deprecated in the future release. Use TCA0_CounterSet instead.
Typedef Documentation
TCA0_cb_t
TCA0_cb_t
Function pointer to the callback function called by TCA while operating in Normal mode. The default value is set to NULL, which means that no callback function will be used.
Function pointer to the callback function called by TCA while operating in Split mode. The default value is set to NULL, which means that no callback function will be used.
Function Documentation
TCA0_CMP0MatchStatusClear()
void TCA0_CMP0MatchStatusClear (void )
Clears the TCA0 Compare 0 Interrupt flag.
None. |
None. |
TCA0_CMP0MatchStatusGet()
bool TCA0_CMP0MatchStatusGet (void )
Returns the status of the TCA0 Compare 0 Interrupt flag.
None. |
True |
- Compare 0 Interrupt flag is set |
False |
- Compare 0 Interrupt flag is not set |
TCA0_CMP1MatchStatusClear()
void TCA0_CMP1MatchStatusClear (void )
Clears the TCA0 Compare 1 Interrupt flag.
None. |
None. |
TCA0_CMP1MatchStatusGet()
bool TCA0_CMP1MatchStatusGet (void )
Returns the status of the TCA0 Compare 1 Interrupt flag.
None. |
True |
- Compare 1 Interrupt flag is set |
False |
- Compare 1 Interrupt flag is not set |
TCA0_CMP2MatchStatusClear()
void TCA0_CMP2MatchStatusClear (void )
Clears the TCA0 Compare 2 Interrupt flag.
None. |
None. |
TCA0_CMP2MatchStatusGet()
bool TCA0_CMP2MatchStatusGet (void )
Returns the status of the TCA0 Compare 2 Interrupt flag.
None. |
True |
- Compare 2 Interrupt flag is set |
False |
- Compare 2 Interrupt flag is not set |
TCA0_Compare0CallbackRegister()
void TCA0_Compare0CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the TCA0 Compare 0 match event.
CallbackHandler |
- Address to the custom callback function |
None. |
TCA0_Compare0Set()
void TCA0_Compare0Set (uint16_t value)
Sets the Compare 0 (CMP0) count value.
Initialize the TCA0 with TCA0_Initialize() before calling this API. |
value |
- Count value written to the CMP0 register |
None. |
TCA0_Compare1CallbackRegister()
void TCA0_Compare1CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the TCA0 Compare 1 match event.
CallbackHandler |
- Address to the custom callback function |
None. |
TCA0_Compare1Set()
void TCA0_Compare1Set (uint16_t value)
Sets the Compare 1 (CMP1) count value.
Initialize the TCA0 with TCA0_Initialize() before calling this API. |
value |
- Count value written to the CMP1 register |
None. |
TCA0_Compare2CallbackRegister()
void TCA0_Compare2CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the TCA0 Compare 2 match event.
CallbackHandler |
- Address to the custom callback function |
None. |
TCA0_Compare2Set()
void TCA0_Compare2Set (uint16_t value)
Sets the Compare 2 (CMP2) count value.
Initialize the TCA0 with TCA0_Initialize() before calling this API. |
value |
- Count value written to the CMP2 register |
None. |
TCA0_CounterGet()
uint16_t TCA0_CounterGet (void )
Returns the current counter value.
None. |
Current count value from the CNT register |
TCA0_CounterSet()
void TCA0_CounterSet (uint16_t count)
Sets the counter value.
count |
- Counter value to be written to the CNT register |
None. |
TCA0_Deinitialize()
void TCA0_Deinitialize (void )
Deinitializes the TCA0 module.
None. |
None. |
TCA0_FrequencyGet()
uint16_t TCA0_FrequencyGet (void )
Returns the frequency count value.
None. |
Frequency count value from the CMP0 register |
TCA0_FrequencySet()
void TCA0_FrequencySet (uint16_t count)
Sets the frequency count value.
count |
- Counter value to be written to the CMP0 register |
None. |
TCA0_Initialize()
void TCA0_Initialize (void )
Initializes the TCA0 module.
None. |
None. |
TCA0_InterruptDisable()
void TCA0_InterruptDisable (void )
Disables the TCA0 interrupts.
None. |
None. |
TCA0_InterruptEnable()
void TCA0_InterruptEnable (void )
Enables the TCA0 interrupts.
None. |
None. |
TCA0_MaxCountGet()
uint16_t TCA0_MaxCountGet (void )
Returns the maximum count value.
None. |
Maximum count value |
TCA0_ModeSet()
void TCA0_ModeSet (TCA_SINGLE_WGMODE_t mode)
Sets the Waveform Generation mode.
Initialize the TCA0 with TCA0_Initialize() before calling this API. |
TCA_SINGLE_WGMODE_t |
mode:
|
None. |
TCA0_OverflowCallbackRegister()
void TCA0_OverflowCallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the TCA0 overflow or underflow event.
CallbackHandler |
- Address to the custom callback function |
None. |
TCA0_OverflowStatusClear()
void TCA0_OverflowStatusClear (void )
Clears the TCA0 Overflow Interrupt flag.
None. |
None. |
TCA0_OverflowStatusGet()
bool TCA0_OverflowStatusGet (void )
Returns the status of the TCA0 Overflow Interrupt flag.
None. |
True |
- Overflow Interrupt flag is set |
False |
- Overflow Interrupt flag is not set |
TCA0_PeriodGet()
uint16_t TCA0_PeriodGet (void )
Returns the current period value.
Initialize the TCA0 with TCA0_Initialize() before calling this API. |
None. |
Period value from the PER register |
TCA0_PeriodSet()
void TCA0_PeriodSet (uint16_t periodVal)
Sets the period value.
Initialize the TCA0 with TCA0_Initialize() before calling this API. |
periodVal |
- Period count value written to the PER register |
None. |
TCA0_Start()
void TCA0_Start (void )
Starts the TCA0.
None. |
None. |
TCA0_Stop()
void TCA0_Stop (void )
Stops the TCA0.
None. |
None. |
TCA0_Tasks()
void TCA0_Tasks (void )
Performs tasks to be executed during the TCA0 interrupt events.
None. |
None. |
TCA0_WO1OffsetGet()
uint16_t TCA0_WO1OffsetGet (void )
Returns the WO1 offset count value.
None. |
Offset count value from the CMP1 register |
TCA0_WO1OffsetSet()
void TCA0_WO1OffsetSet (uint16_t count)
Sets the WO1 offset count value.
count |
- Offset count value to be written to the CMP1 register |
None. |
TCA0_WO2OffsetGet()
uint16_t TCA0_WO2OffsetGet (void )
Returns the WO2 offset count value.
None. |
Offset count value from the CMP2 register |
TCA0_WO2OffsetSet()
void TCA0_WO2OffsetSet (uint16_t count)
Sets the WO2 offset count value.
count |
- Offset count value to be written to the CMP2 register |
None. |
3.14.4.6.2 TCA0 in Split Mode
This file contains API prototypes for the TCA0 driver in Split (8-bit) mode.
Module description
This file contains API prototypes for the TCA0 driver in Split (8-bit) mode.
Definitions
#define TCA0_MAX_COUNT (255U)
Defines the maximum count of the timer.
#define TCA0_CLOCK_FREQ (4000000UL)
Defines the timer prescaled clock frequency in hertz.
#define TCA0_ReadHighCount TCA0_HighCounterGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ReadHighCount will be deprecated in the future release. Use TCA0_HighCounterGet instead.
#define TCA0_WriteHighCount TCA0_HighCounterSet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_WriteHighCount will be deprecated in the future release. Use TCA0_HighCounterSet instead.
#define TCA0_ReadLowCount TCA0_LowCounterGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ReadLowCount will be deprecated in the future release. Use TCA0_LowCounterGet instead.
#define TCA0_WriteLowCount TCA0_LowCounterSet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_WriteLowCount will be deprecated in the future release. Use TCA0_LowCounterSet instead.
#define TCA0_ClearHUNFInterruptFlag TCA0_HUNFInterruptFlagClear
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ClearHUNFInterruptFlag will be deprecated in the future release. Use TCA0_HUNFInterruptFlagClear instead.
#define TCA0_IsHUNFInterruptFlagSet TCA0_HUNFInterruptStatusGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_IsHUNFInterruptFlagSet will be deprecated in the future release. Use TCA0_HUNFInterruptStatusGet instead.
#define TCA0_ClearLUNFInterruptFlag TCA0_LUNFInterruptFlagClear
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ClearLUNFInterruptFlag will be deprecated in the future release. Use TCA0_LUNFInterruptFlagClear instead.
#define TCA0_IsLUNFInterruptFlagSet TCA0_LUNFInterruptStatusGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_IsLUNFInterruptFlagSet will be deprecated in the future release. Use TCA0_LUNFInterruptStatusGet instead.
#define TCA0_ClearLCMP0InterruptFlag TCA0_LCMP0InterruptFlagClear
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ClearLCMP0InterruptFlag will be deprecated in the future release. Use TCA0_LCMP0InterruptFlagClear instead.
#define TCA0_IsLCMP0InterruptFlagSet TCA0_LCMP0InterruptStatusGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_IsLCMP0InterruptFlagSet will be deprecated in the future release. Use TCA0_LCMP0InterruptStatusGet instead.
#define TCA0_ClearLCMP1InterruptFlag TCA0_LCMP1InterruptFlagClear
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ClearLCMP1InterruptFlag will be deprecated in the future release. Use TCA0_LCMP1InterruptFlagClear instead.
#define TCA0_IsLCMP1InterruptFlagSet TCA0_LCMP1InterruptStatusGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_IsLCMP1InterruptFlagSet will be deprecated in the future release. Use TCA0_LCMP1InterruptStatusGet instead.
#define TCA0_ClearLCMP2InterruptFlag TCA0_LCMP2InterruptFlagClear
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ClearHUNFInterruptFlag will be deprecated in the future release. Use TCA0_LCMP2InterruptFlagClear instead.
#define TCA0_IsLCMP2InterruptFlagSet TCA0_LCMP2InterruptStatusGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_IsLCMP2InterruptFlagSet will be deprecated in the future release. Use TCA0_LCMP2InterruptStatusGet instead.
Functions
void TCA0_Initialize (void)
Initializes the TCA0 module.
void TCA0_Deinitialize (void)
Deinitializes the TCA0 module.
void TCA0_Start (void)
Starts the TCA0.
void TCA0_Stop (void)
Stops the TCA0.
void TCA0_LowCounterSet (uint8_t timerVal)
Sets the counter value for the Low Byte Timer.
uint8_t TCA0_LowCounterGet (void)
Returns the Low Byte Timer counter value.
uint8_t TCA0_HighCounterGet (void)
Returns the High Byte Timer counter value.
void TCA0_HighCounterSet (uint8_t timerVal)
Sets the counter value for the High Byte Timer.
void TCA0_HighPeriodSet (uint8_t periodVal)
Sets the period count value for the High Byte Timer.
void TCA0_LowPeriodSet (uint8_t periodVal)
Sets the period count value for the Low Byte Timer.
uint8_t TCA0_HighPeriodGet (void)
Returns the period count value of the High Byte Timer.
uint8_t TCA0_LowPeriodGet (void)
Returns the period count value of the Low Byte Timer.
uint8_t TCA0_MaxCountGet (void)
Returns the maximum timer count value.
void TCA0_HUNFInterruptFlagClear (void)
Clears the High Byte Timer Underflow Interrupt flag.
bool TCA0_HUNFInterruptStatusGet (void)
Returns the status of the High Byte Timer Underflow Interrupt flag.
void TCA0_LUNFInterruptFlagClear (void)
Clears the Low Byte Timer Underflow Interrupt flag.
bool TCA0_LUNFInterruptStatusGet (void)
Returns the status of the Low Byte Timer Underflow Interrupt flag.
void TCA0_LCMP0InterruptFlagClear (void)
Clears the Low Byte Timer Compare Channel 0 Match Interrupt flag.
bool TCA0_LCMP0InterruptStatusGet (void)
Returns the status of the Low Byte Timer Compare Channel 0 Match Interrupt flag.
void TCA0_LCMP1InterruptFlagClear (void)
Clears the Low Byte Timer Compare Channel 1 Match Interrupt flag.
bool TCA0_LCMP1InterruptStatusGet (void)
Returns the status of the Low Byte Timer Compare Channel 1 Match Interrupt flag.
void TCA0_LCMP2InterruptFlagClear (void)
Clears the Low Byte Timer Compare Channel 2 Match Interrupt flag.
void TCA0_InterruptEnable (void)
Enables the timer interrupts in Split mode.
void TCA0_InterruptDisable (void)
Disables the timer interrupts in Split mode.
bool TCA0_LCMP2InterruptStatusGet (void)
Returns the status of the Low Byte Timer Compare Channel 2 Match Interrupt flag.
void TCA0_HighCountCallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the High Byte Timer underflow event.
void TCA0_LowCompare0CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the Low Byte Timer Compare 0 match event.
void TCA0_LowCompare1CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the Low Byte Timer Compare 1 match event.
void TCA0_LowCompare2CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the Low Byte Timer Compare 2 match event.
void TCA0_LowCountCallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the Low Byte Timer underflow event.
void TCA0_Tasks (void)
Performs tasks to be executed during the timer interrupt events.
Definition Documentation
TCA0_ClearHUNFInterruptFlag
#define TCA0_ClearHUNFInterruptFlag TCA0_HUNFInterruptFlagClear
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ClearHUNFInterruptFlag will be deprecated in the future release. Use TCA0_HUNFInterruptFlagClear instead.
TCA0_ClearLCMP0InterruptFlag
#define TCA0_ClearLCMP0InterruptFlag TCA0_LCMP0InterruptFlagClear
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ClearLCMP0InterruptFlag will be deprecated in the future release. Use TCA0_LCMP0InterruptFlagClear instead.
TCA0_ClearLCMP1InterruptFlag
#define TCA0_ClearLCMP1InterruptFlag TCA0_LCMP1InterruptFlagClear
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ClearLCMP1InterruptFlag will be deprecated in the future release. Use TCA0_LCMP1InterruptFlagClear instead.
TCA0_ClearLCMP2InterruptFlag
#define TCA0_ClearLCMP2InterruptFlag TCA0_LCMP2InterruptFlagClear
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ClearHUNFInterruptFlag will be deprecated in the future release. Use TCA0_LCMP2InterruptFlagClear instead.
TCA0_ClearLUNFInterruptFlag
#define TCA0_ClearLUNFInterruptFlag TCA0_LUNFInterruptFlagClear
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ClearLUNFInterruptFlag will be deprecated in the future release. Use TCA0_LUNFInterruptFlagClear instead.
TCA0_CLOCK_FREQ
#define TCA0_CLOCK_FREQ (4000000UL)
Defines the timer prescaled clock frequency in hertz.
TCA0_IsHUNFInterruptFlagSet
#define TCA0_IsHUNFInterruptFlagSet TCA0_HUNFInterruptStatusGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_IsHUNFInterruptFlagSet will be deprecated in the future release. Use TCA0_HUNFInterruptStatusGet instead.
TCA0_IsLCMP0InterruptFlagSet
#define TCA0_IsLCMP0InterruptFlagSet TCA0_LCMP0InterruptStatusGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_IsLCMP0InterruptFlagSet will be deprecated in the future release. Use TCA0_LCMP0InterruptStatusGet instead.
TCA0_IsLCMP1InterruptFlagSet
#define TCA0_IsLCMP1InterruptFlagSet TCA0_LCMP1InterruptStatusGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_IsLCMP1InterruptFlagSet will be deprecated in the future release. Use TCA0_LCMP1InterruptStatusGet instead.
TCA0_IsLCMP2InterruptFlagSet
#define TCA0_IsLCMP2InterruptFlagSet TCA0_LCMP2InterruptStatusGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_IsLCMP2InterruptFlagSet will be deprecated in the future release. Use TCA0_LCMP2InterruptStatusGet instead.
TCA0_IsLUNFInterruptFlagSet
#define TCA0_IsLUNFInterruptFlagSet TCA0_LUNFInterruptStatusGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_IsLUNFInterruptFlagSet will be deprecated in the future release. Use TCA0_LUNFInterruptStatusGet instead.
TCA0_MAX_COUNT
#define TCA0_MAX_COUNT (255U)
Defines the maximum count of the timer.
MISRA C:2012 Deviation Advisory: misra-c2012-2.5
Justification: MCC Melody drivers provide macros that can be added to an application. It depends on the application whether a macro is used or not.TCA0_ReadHighCount
#define TCA0_ReadHighCount TCA0_HighCounterGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ReadHighCount will be deprecated in the future release. Use TCA0_HighCounterGet instead.
MISRA C:2012 Deviation Advisory: misra-c2012-2.5
Justification: MCC Melody drivers provide macros that can be added to an application. It depends on the application whether a macro is used or not.TCA0_ReadLowCount
#define TCA0_ReadLowCount TCA0_LowCounterGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ReadLowCount will be deprecated in the future release. Use TCA0_LowCounterGet instead.
TCA0_WriteHighCount
#define TCA0_WriteHighCount TCA0_HighCounterSet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_WriteHighCount will be deprecated in the future release. Use TCA0_HighCounterSet instead.
TCA0_WriteLowCount
#define TCA0_WriteLowCount TCA0_LowCounterSet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_WriteLowCount will be deprecated in the future release. Use TCA0_LowCounterSet instead.
Function Documentation
TCA0_Deinitialize()
void TCA0_Deinitialize (void )
Deinitializes the TCA0 module.
None. |
None. |
TCA0_HighCountCallbackRegister()
void TCA0_HighCountCallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the High Byte Timer underflow event.
CallbackHandler |
- Address to the custom callback function |
None. |
TCA0_HighCounterGet()
uint8_t TCA0_HighCounterGet (void )
Returns the High Byte Timer counter value.
None. |
Counter value from the HCNT register |
TCA0_HighCounterSet()
void TCA0_HighCounterSet (uint8_t timerVal)
Sets the counter value for the High Byte Timer.
timerVal |
- Counter value to be written to the HCNT register |
None. |
TCA0_HighPeriodGet()
uint8_t TCA0_HighPeriodGet (void )
Returns the period count value of the High Byte Timer.
None. |
Period count value from the HPER register |
TCA0_HighPeriodSet()
void TCA0_HighPeriodSet (uint8_t periodVal)
Sets the period count value for the High Byte Timer.
periodVal |
- Period count value written to the HPER register |
None. |
TCA0_HUNFInterruptFlagClear()
void TCA0_HUNFInterruptFlagClear (void )
Clears the High Byte Timer Underflow Interrupt flag.
None. |
None. |
TCA0_HUNFInterruptStatusGet()
bool TCA0_HUNFInterruptStatusGet (void )
Returns the status of the High Byte Timer Underflow Interrupt flag.
None. |
True |
- High Byte Underflow Interrupt flag is set |
False |
- High Byte Underflow Interrupt flag is not set |
TCA0_Initialize()
void TCA0_Initialize (void )
Initializes the TCA0 module.
None. |
None. |
Initializes the TCA0 module. This routine must be called before any other TCA0 routines.
None. |
None. |
TCA0_InterruptDisable()
void TCA0_InterruptDisable (void )
Disables the timer interrupts in Split mode.
None. |
None. |
TCA0_InterruptEnable()
void TCA0_InterruptEnable (void )
Enables the timer interrupts in Split mode.
None. |
None. |
TCA0_LCMP0InterruptFlagClear()
void TCA0_LCMP0InterruptFlagClear (void )
Clears the Low Byte Timer Compare Channel 0 Match Interrupt flag.
None. |
None. |
TCA0_LCMP0InterruptStatusGet()
bool TCA0_LCMP0InterruptStatusGet (void )
Returns the status of the Low Byte Timer Compare Channel 0 Match Interrupt flag.
None. |
True |
- Low Byte Timer Compare Channel 0 Match Interrupt flag is set |
False |
- Low Byte Timer Compare Channel 0 Match Interrupt flag is not set |
TCA0_LCMP1InterruptFlagClear()
void TCA0_LCMP1InterruptFlagClear (void )
Clears the Low Byte Timer Compare Channel 1 Match Interrupt flag.
None. |
None. |
TCA0_LCMP1InterruptStatusGet()
bool TCA0_LCMP1InterruptStatusGet (void )
Returns the status of the Low Byte Timer Compare Channel 1 Match Interrupt flag.
None. |
True |
- Low Byte Timer Compare Channel 1 Match Interrupt flag is set |
False |
- Low Byte Timer Compare Channel 1 Match Interrupt flag is not set |
TCA0_LCMP2InterruptFlagClear()
void TCA0_LCMP2InterruptFlagClear (void )
Clears the Low Byte Timer Compare Channel 2 Match Interrupt flag.
None. |
None. |
TCA0_LCMP2InterruptStatusGet()
bool TCA0_LCMP2InterruptStatusGet (void )
Returns the status of the Low Byte Timer Compare Channel 2 Match Interrupt flag.
None. |
True |
- Low Byte Timer Compare Channel 2 Match Interrupt flag is set |
False |
- Low Byte Timer Compare Channel 2 Match Interrupt flag is not set |
TCA0_LowCompare0CallbackRegister()
void TCA0_LowCompare0CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the Low Byte Timer Compare 0 match event.
CallbackHandler |
- Address to the custom callback function |
None. |
TCA0_LowCompare1CallbackRegister()
void TCA0_LowCompare1CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the Low Byte Timer Compare 1 match event.
CallbackHandler |
- Address to the custom callback function |
None. |
TCA0_LowCompare2CallbackRegister()
void TCA0_LowCompare2CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the Low Byte Timer Compare 2 match event.
CallbackHandler |
- Address to the custom callback function |
None. |
TCA0_LowCountCallbackRegister()
void TCA0_LowCountCallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the Low Byte Timer underflow event.
CallbackHandler |
- Address to the custom callback function |
None. |
TCA0_LowCounterGet()
uint8_t TCA0_LowCounterGet (void )
Returns the Low Byte Timer counter value.
None. |
Counter value from the LCNT register |
TCA0_LowCounterSet()
void TCA0_LowCounterSet (uint8_t timerVal)
Sets the counter value for the Low Byte Timer.
timerVal |
- Counter value to be written to the LCNT register |
None. |
TCA0_LowPeriodGet()
uint8_t TCA0_LowPeriodGet (void )
Returns the period count value of the Low Byte Timer.
None. |
Period count value from the LPER register |
TCA0_LowPeriodSet()
void TCA0_LowPeriodSet (uint8_t periodVal)
Sets the period count value for the Low Byte Timer.
periodVal |
- Period count value written to the LPER register |
None. |
TCA0_LUNFInterruptFlagClear()
void TCA0_LUNFInterruptFlagClear (void )
Clears the Low Byte Timer Underflow Interrupt flag.
None. |
None. |
TCA0_LUNFInterruptStatusGet()
bool TCA0_LUNFInterruptStatusGet (void )
Returns the status of the Low Byte Timer Underflow Interrupt flag.
None. |
True |
- Low Byte Underflow Interrupt flag is set |
False |
- Low Byte Underflow Interrupt flag is not set |
TCA0_MaxCountGet()
uint8_t TCA0_MaxCountGet (void )
Returns the maximum timer count value.
None. |
Maximum count value |
Returns the maximum timer count value.
None. |
Maximum count value |
TCA0_Start()
void TCA0_Start (void )
Starts the TCA0.
None. |
None. |
Starts TCA0.
None. |
None. |
TCA0_Stop()
void TCA0_Stop (void )
Stops the TCA0.
None. |
None. |
Stops TCA0.
None. |
None. |
TCA0_Tasks()
void TCA0_Tasks (void )
Performs tasks to be executed during the timer interrupt events.
None. |
None. |
3.14.4.7 TCA Examples
This section explains various use case examples of the Timer module within an MPLAB® Code Configurator (MCC) Melody Project.
3.14.4.7.1 TCA PLIB Examples
4 ms/8 ms Timer Period Change in Non-Interrupt Mode
This use case configures the TCA0 PLIB to generate the timer period. The period of a timer is changed at run time during each overflow event. The callback function is used to change the timer period.
-
System>CLKCTRL:
-
Clock Selection: Internal high-frequency oscillator
-
Oscillator Frequency Selection: 4 MHz system clock (default)
-
-
System>Pins:
-
Pin Grid View: Select LED pin as output (Check the schematic for your board)
-
Pins: Rename Custom Name to "LED"
-
-
Drivers>TCA0:
-
Timer Enable: False
-
Timer Mode: 16-bit (Normal)
-
Requested Time Period: 10 ms
-
Waveform Generation Mode: Normal Mode
-
Overflow Interrupt Enable: False
-
After configuring the components as described above, click 'Generate' to generate the code. Then add the following code snippets to your application:
#include "mcc_generated_files/system/system.h" /* * Development Board: AVR128DA48 Curiosity Nano Board * MCC Configuration: * CLKCTRL module: Clock Selection - Internal high-frequency oscillator, Oscillator Frequency Selection - 4 MHz system clock (default) * TCA0 module: Timer Enable - False, Timer Mode - 16-bit (Normal), Requested Time Period - 10 ms, Waveform Generation Mode - Normal Mode * Pins module: PC6 - GPIO Output, CustomName - LED */ #define USE_TASKS_API 0 #define MS_TO_TICKS(ms) (((TCA0_CLOCK_FREQ * (ms)) / 1000UL) - 1UL) #define LED_4_MS MS_TO_TICKS(4UL) #define LED_8_MS MS_TO_TICKS(8UL) static void Timer_PeriodChange(void) { static volatile bool changePeriod = false; LED_Toggle(); TCA0_Stop(); uint16_t maxCount = TCA0_MaxCountGet(); uint16_t newPeriod = changePeriod ? LED_4_MS:LED_8_MS; if(maxCount > newPeriod) { TCA0_PeriodSet(newPeriod); } else { // Invalid period } changePeriod = !changePeriod; TCA0_Start(); } int main(void) { SYSTEM_Initialize(); TCA0_PeriodSet(LED_4_MS); TCA0_ClearOverflowInterruptFlag(); #if USE_TASKS_API TCA0_OverflowCallbackRegister(Timer_PeriodChange); #endif TCA0_Start(); while(1) { #if USE_TASKS_API TCA0_Tasks(); #else if(1U == TCA0_IsOverflowInterruptFlagSet()) { Timer_PeriodChange(); TCA0_ClearOverflowInterruptFlag(); } #endif } }
4 ms Timer Period in Interrupt Mode
This use case configures the TCA0 PLIB to generate the overflow interrupt at a period of 4 ms, while toggling an LED. This use case uses the generated APIs to set the timer period.
-
System>CLKCTRL:
-
Clock Selection: Internal high-frequency oscillator
-
Oscillator Frequency Selection: 4 MHz system clock (default)
-
-
System>Pins:
-
Pin Grid View: Select LED pin as output (Check the schematic for your board)
-
Pins: Rename Custom Name to "LED"
-
-
Drivers>TCA0:
-
Timer Enable: False
-
Timer Mode: 16-bit (Normal)
-
Clock Select: System Clock
-
Waveform Generation Mode: Normal Mode
-
Overflow Interrupt Enable: True
-
After configuring the components as described above, click 'Generate' to generate the code. Then add the following code snippets to your application:
#include "mcc_generated_files/system/system.h" /* * Development Board: AVR128DA48 Curiosity Nano Board * MCC Configuration: * CLKCTRL module: Clock Selection - Internal high-frequency oscillator, Oscillator Frequency Selection - 4 MHz system clock(default) * TCA0 module: Timer Enable - False, Timer Mode - 16-bit (Normal), Clock Selection - System Clock, Overflow Interrupt Enable - True * Pins module: PC6 - GPIO Output, CustomName - LED */ #define MS_TO_TICKS(ms) (((TCA0_CLOCK_FREQ * (ms)) / 1000UL) - 1UL) #define LED_4_MS MS_TO_TICKS(4UL) void Custom_Callback(void) { LED_Toggle(); } int main(void) { SYSTEM_Initialize(); TCA0_CounterSet(0); if(TCA0_MaxCountGet() > LED_4_MS) { TCA0_PeriodSet(LED_4_MS); } else { // Invalid period // Generate default timer period } TCA0_OverflowCallbackRegister(Custom_Callback); TCA0_Start(); sei(); while(1) { } }
Timer Wake From Sleep at Every 5s
This use case configures the TCA0 PLIB to wake the microcontroller from Sleep mode, every five seconds. The wake up event toggles an LED then puts the MCU back to Sleep.
-
System>CLKCTRL:
-
Clock Selection: Internal high-frequency oscillator
-
Oscillator Frequency Selection: 4 MHz system clock (default)
-
-
System>Pins:
-
Pin Grid View: Select LED pin as output (Check the schematic for your board)
-
Pins: Rename Custom Name to "LED"
-
-
Drivers>TCA0:
-
Timer Enable: True
-
Clock Select: System Clock/1024
-
Run in Standby: True
-
Requested Period: 5s
-
Overflow Interrupt Enable: True
-
After configuring the components as described above, click 'Generate' to generate the code. Then add the following code snippets to your application:
#include "mcc_generated_files/system/system.h" #include<avr/sleep.h> /* * Development Board: AVR128DA48 Curiosity Nano Board * MCC Configuration: * CLKCTRL module: Clock Selection - Internal high-frequency oscillator, Oscillator Frequency Selection - 4 MHz system clock (default) (4 MHz) * TCA0 module: Timer Enable - True, Clock Select - System Clock/1024, Requested Period - 5s, Run in Standby - True, Overflow Interrupt Enable - True * Pins module: PC6 - GPIO Output, CustomName - LED */ int main(void) { SYSTEM_Initialize(); // Enable the Global Interrupts sei(); while(1) { LED_Toggle(); sleep_mode(); // Add your code here to execute after exiting Sleep mode } }
250 Hz Output Signal on General Purpose Input/Output (GPIO) Pin
This use case configures the TCA0 PLIB to generate a signal of a specified frequency on a pin.
Note: It is only possible to select a single output frequency, i.e., the frequency will be the same between output channels even when set to different values.
-
System>CLKCTRL:
-
Clock Selection: Internal high-frequency oscillator
-
Oscillator Frequency Selection: 4 MHz system clock (default)
-
-
Drivers>TCA0:
-
Timer Enable: True
-
Clock Select: System Clock
-
Waveform Generation Mode: Frequency Generation Mode
-
Requested Frequency in WO0, WO1, WO2 pins: 250 Hz
-
-
System>Pins:
-
Pin Grid View: TCA0 WO0 - Select GPIO to use for 250 Hz signal
-
After configuring the components as described above, click 'Generate' to generate the code. Then add the following code snippets to your application:
#include "mcc_generated_files/system/system.h" /* * Example: 250 Hz Output Signal on General Purpose Input/Output (GPIO) Pin * Development Board: AVR128DA48 Curiosity Nano Board * MCC Configuration: * CLKCTRL module: Clock Selection - Internal high-frequency oscillator, Oscillator Frequency Selection - 4 MHz system clock (default) (4 MHz) * TCA0 module: Timer Enable - True, Clock Selection - System Clock, Waveform Generation Mode - Frequency Generation Mode, Requested Frequency in WO0, WO1, WO2 pins - 250 Hz * Pins: RD0 - WO0 */ int main(void) { SYSTEM_Initialize(); while(1) { } }
10 ms/5 ms PWM Period Signals with Various Duty Cycles Utilizing Split Mode
This use case configures the TCA0 PLIB in Split mode to generate 10 ms/5 ms PWM signals with various duty cycles on the selected waveform output pins.
-
System>CLKCTRL:
-
Clock Selection: Internal high-frequency oscillator
-
Oscillator Frequency Selection: 4 MHz system clock (default)
-
-
Drivers>TCA0:
-
Timer Enable: True
-
Timer Mode: 8-bit (Split)
-
Clock Select: System Clock/256
-
Requested High Byte Timer Period: 10 ms
-
Requested Low Byte Timer Period: 5 ms
-
Compare Channel 0 Enable: True
-
Duty Cycle 0: 20%
-
Compare Channel 3 Enable: True
-
Duty Cycle 1: 40%
-
-
System>Pins:
-
Pin Grid View: TCA0 WO0, WO3 - Select GPIO for PWM signals
-
After configuring the components as described above, click 'Generate' to generate the code. Then add the following code snippets to your application:
#include "mcc_generated_files/system/system.h" /* * Development Board: AVR128DA48 Curiosity Nano Board * MCC Configuration: * CLKCTRL module: Clock Selection - Internal high-frequency oscillator, Oscillator Frequency Selection - 4 MHz system clock (default) * TCA0 module: Timer Enable - True, Timer Mode - 8-bit (Split), Clock Select - System Clock/256, Requested High Byte Timer Period - 10 ms, Requested Low Byte Timer Period - 5 ms, * Compare Channel 0 Enable - True, Compare Channel 3 Enable - True, * Duty Cycle 0 - 20, Duty Cycle 3 - 40 * Pins: RD0 - WO0, RD3 - WO3 */ int main(void) { SYSTEM_Initialize(); while(1) { } }
3.14.4.8 File Documentation
3.14.4.8.1 source/tca0.c File Reference
Driver implementation for the TCA0 module in Normal (16-bit) mode.
#include "../tca0.h"
Functions
void TCA0_Initialize (void)
Initializes the TCA0 module.
void TCA0_Deinitialize (void)
Deinitializes the TCA0 module.
void TCA0_Start (void)
Starts the TCA0.
void TCA0_Stop (void)
Stops the TCA0.
void TCA0_CounterSet (uint16_t count)
Sets the counter value.
uint16_t TCA0_CounterGet (void)
Returns the current counter value.
void TCA0_PeriodSet (uint16_t periodVal)
Sets the period value.
uint16_t TCA0_PeriodGet (void)
Returns the current period value.
void TCA0_Compare0Set (uint16_t value)
Sets the Compare 0 (CMP0) count value.
void TCA0_Compare1Set (uint16_t value)
Sets the Compare 1 (CMP1) count value.
void TCA0_Compare2Set (uint16_t value)
Sets the Compare 2 (CMP2) count value.
uint16_t TCA0_MaxCountGet (void)
Returns the maximum count value.
void TCA0_ModeSet (TCA_SINGLE_WGMODE_t mode)
Sets the Waveform Generation mode.
void TCA0_OverflowStatusClear (void)
Clears the TCA0 Overflow Interrupt flag.
bool TCA0_OverflowStatusGet (void)
Returns the status of the TCA0 Overflow Interrupt flag.
void TCA0_CMP0MatchStatusClear (void)
Clears the TCA0 Compare 0 Interrupt flag.
bool TCA0_CMP0MatchStatusGet (void)
Returns the status of the TCA0 Compare 0 Interrupt flag.
void TCA0_CMP1MatchStatusClear (void)
Clears the TCA0 Compare 1 Interrupt flag.
bool TCA0_CMP1MatchStatusGet (void)
Returns the status of the TCA0 Compare 1 Interrupt flag.
void TCA0_CMP2MatchStatusClear (void)
Clears the TCA0 Compare 2 Interrupt flag.
bool TCA0_CMP2MatchStatusGet (void)
Returns the status of the TCA0 Compare 2 Interrupt flag.
void TCA0_Tasks (void)
Performs tasks to be executed during the TCA0 interrupt events.
void TCA0_OverflowCallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the TCA0 overflow or underflow event.
void TCA0_Compare0CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the TCA0 Compare 0 match event.
void TCA0_Compare1CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the TCA0 Compare 1 match event.
void TCA0_Compare2CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the TCA0 Compare 2 match event.
Variables
static void(* TCA0_CMP0Callback )(void) = NULL
static void(* TCA0_CMP1Callback )(void) = NULL
static void(* TCA0_CMP2Callback )(void) = NULL
static void(* TCA0_OVFCallback )(void) = NULL
Detailed Description
Driver implementation for the TCA0 module in Normal (16-bit) mode.
This file contains the API implementations for TCA0 module in Split (8-bit) mode.
Timer Driver implementation for the TCA0 module.
TCA0 Generated Driver File
TCA0 Generated Timer Driver File
Variable Documentation
TCA0_CMP0Callback
void(* TCA0_CMP0Callback) (void) = NULL[static]
TCA0_CMP1Callback
void(* TCA0_CMP1Callback) (void) = NULL[static]
TCA0_CMP2Callback
void(* TCA0_CMP2Callback) (void) = NULL[static]
TCA0_OVFCallback
void(* TCA0_OVFCallback) (void) = NULL[static]
3.14.4.8.2 source/tca0.h File Reference
This file contains the deprecated macros or APIs for the TCA0 driver.
#include <stdint.h> #include <stdbool.h> #include "../system/utils/compiler.h" #include "./tca0_deprecated.h"
Functions
void TCA0_Initialize (void)
Initializes the TCA0 module.
void TCA0_Deinitialize (void)
Deinitializes the TCA0 module.
void TCA0_Start (void)
Starts the TCA0.
void TCA0_Stop (void)
Stops the TCA0.
uint16_t TCA0_CounterGet (void)
Returns the current counter value.
void TCA0_CounterSet (uint16_t count)
Sets the counter value.
uint16_t TCA0_PeriodGet (void)
Returns the current period value.
void TCA0_PeriodSet (uint16_t periodVal)
Sets the period value.
void TCA0_Compare0Set (uint16_t value)
Sets the Compare 0 (CMP0) count value.
void TCA0_Compare1Set (uint16_t value)
Sets the Compare 1 (CMP1) count value.
void TCA0_Compare2Set (uint16_t value)
Sets the Compare 2 (CMP2) count value.
uint16_t TCA0_MaxCountGet (void)
Returns the maximum count value.
void TCA0_FrequencySet (uint16_t count)
Sets the frequency count value.
uint16_t TCA0_FrequencyGet (void)
Returns the frequency count value.
void TCA0_WO1OffsetSet (uint16_t count)
Sets the WO1 offset count value.
uint16_t TCA0_WO1OffsetGet (void)
Returns the WO1 offset count value.
void TCA0_WO2OffsetSet (uint16_t count)
Sets the WO2 offset count value.
uint16_t TCA0_WO2OffsetGet (void)
Returns the WO2 offset count value.
void TCA0_ModeSet (TCA_SINGLE_WGMODE_t mode)
Sets the Waveform Generation mode.
void TCA0_OverflowStatusClear (void)
Clears the TCA0 Overflow Interrupt flag.
bool TCA0_OverflowStatusGet (void)
Returns the status of the TCA0 Overflow Interrupt flag.
void TCA0_CMP0MatchStatusClear (void)
Clears the TCA0 Compare 0 Interrupt flag.
bool TCA0_CMP0MatchStatusGet (void)
Returns the status of the TCA0 Compare 0 Interrupt flag.
void TCA0_CMP1MatchStatusClear (void)
Clears the TCA0 Compare 1 Interrupt flag.
bool TCA0_CMP1MatchStatusGet (void)
Returns the status of the TCA0 Compare 1 Interrupt flag.
void TCA0_CMP2MatchStatusClear (void)
Clears the TCA0 Compare 2 Interrupt flag.
bool TCA0_CMP2MatchStatusGet (void)
Returns the status of the TCA0 Compare 2 Interrupt flag.
void TCA0_InterruptEnable (void)
Enables the TCA0 interrupts.
void TCA0_InterruptDisable (void)
Disables the TCA0 interrupts.
void TCA0_OverflowCallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the TCA0 overflow or underflow event.
void TCA0_Compare0CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the TCA0 Compare 0 match event.
void TCA0_Compare1CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the TCA0 Compare 1 match event.
void TCA0_Compare2CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the TCA0 Compare 2 match event.
void TCA0_Tasks (void)
Performs tasks to be executed during the TCA0 interrupt events.
Macros
#define TCA0_MAX_COUNT (65535U)
Defines the maximum count of the timer.
#define TCA0_CLOCK_FREQ (4000000UL)
Defines the timer prescaled clock frequency in hertz.
Typedefs
typedef void(* TCA0_cb_t) (void)
Function pointer to the callback function called by TCA while operating in Normal mode. The default value is set to NULL, which means that no callback function will be used.
Detailed Description
This file contains the deprecated macros or APIs for the TCA0 driver.
This file contains API prototypes and other data types for the TCA0 Timer Driver.
TCA0 Generated Driver API Header File
TCA0 Generated Driver API Header File
TCA0 Generated Timer Driver API Header File
3.14.4.8.3 source/tca0_deprecated.h File Reference
Macros
#define TCA0_Read TCA0_CounterGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_Read will be deprecated in the future release. Use TCA0_CounterGet instead.
#define TCA0_Write TCA0_PeriodSet
Defines the Custom Name for the TCA0_PeriodSet API. The TCA0_Write will be deprecated in the future release. Use TCA0_PeriodSet instead.
#define TCA0_ClearOverflowInterruptFlag TCA0_OverflowStatusClear
Defines the Custom Name for the TCA0_OverflowStatusClear API. The TCA0_ClearOverflowInterruptFlag will be deprecated in the future release. Use TCA0_OverflowStatusClear instead.
#define TCA0_IsOverflowInterruptFlagSet TCA0_OverflowStatusGet
Defines the Custom Name for the TCA0_OverflowStatusGet API. The TCA0_IsOverflowInterruptFlagSet will be deprecated in the future release. Use TCA0_OverflowStatusGet instead.
#define TCA0_ClearCMP0InterruptFlag TCA0_CMP0MatchStatusClear
Defines the Custom Name for the TCA0_CMP0MatchStatusClear API. The TCA0_ClearCMP0InterruptFlag will be deprecated in the future release. Use TCA0_CMP0MatchStatusClear instead.
#define TCA0_IsCMP0InterruptFlagSet TCA0_CMP0MatchStatusGet
Defines the Custom Name for the TCA0_CMP0MatchStatusGet API. The TCA0_IsCMP0InterruptFlagSet will be deprecated in the future release. Use TCA0_CMP0MatchStatusGet instead.
#define TCA0_ClearCMP1InterruptFlag TCA0_CMP1MatchStatusClear
Defines the Custom Name for the TCA0_CMP1MatchStatusClear API. The TCA0_ClearCMP1InterruptFlag will be deprecated in the future release. Use TCA0_CMP1MatchStatusClear instead.
#define TCA0_IsCMP1InterruptFlagSet TCA0_CMP1MatchStatusGet
Defines the Custom Name for the TCA0_CMP1MatchStatusGet API. The TCA0_IsCMP1InterruptFlagSet will be deprecated in the future release. Use TCA0_CMP1MatchStatusGet instead.
#define TCA0_ClearCMP2InterruptFlag TCA0_CMP2MatchStatusClear
Defines the Custom Name for the TCA0_CMP2MatchStatusClear API. The TCA0_ClearCMP2InterruptFlag will be deprecated in the future release. Use TCA0_CMP2MatchStatusClear instead.
#define TCA0_IsCMP2InterruptFlagSet TCA0_CMP2MatchStatusGet
Defines the Custom Name for the TCA0_CMP2MatchStatusGet API. The TCA0_IsCMP2InterruptFlagSet will be deprecated in the future release. Use TCA0_CMP2MatchStatusGet instead.
#define TCA0_WaveformFreqRegCountSet TCA0_FrequencySet
Defines the Custom Name for the TCA0_FrequencySet API. The TCA0_WaveformFreqRegCountSet will be deprecated in the future release. Use TCA0_FrequencySet instead.
#define TCA0_WaveformFreqRegCountGet TCA0_FrequencyGet
Defines the Custom Name for the TCA0_FrequencyGet API. The TCA0_WaveformFreqRegCountGet will be deprecated in the future release. Use TCA0_FrequencyGet instead.
#define TCA0_WO1OffsetRegCountSet TCA0_WO1OffsetSet
Defines the Custom Name for the TCA0_WO1OffsetSet API. The TCA0_WO1OffsetRegCountSet will be deprecated in the future release. Use TCA0_WO1OffsetSet instead.
#define TCA0_WO1OffsetRegCountGet TCA0_WO1OffsetGet
Defines the Custom Name for the TCA0_WO1OffsetGet API. The TCA0_WO1OffsetRegCountGet will be deprecated in the future release. Use TCA0_WO1OffsetGet instead.
#define TCA0_WO2OffsetRegCountSet TCA0_WO2OffsetSet
Defines the Custom Name for the TCA0_WO2OffsetSet API. The TCA0_WO2OffsetRegCountSet will be deprecated in the future release. Use TCA0_WO2OffsetSet instead.
#define TCA0_WO2OffsetRegCountGet TCA0_WO2OffsetGet
Defines the Custom Name for the TCA0_WO2OffsetGet API. The TCA0_WO2OffsetRegCountGet will be deprecated in the future release. Use TCA0_WO2OffsetGet instead.
#define TCA0CounterGet TCA0_CounterGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0CounterGet will be deprecated in the future release. Use TCA0_CounterGet instead.
#define TCA0CounterSet TCA0_CounterSet
Defines the Custom Name for the TCA0_CounterSet API. The TCA0CounterSet will be deprecated in the future release. Use TCA0_CounterSet instead.
3.14.4.8.4 source/tca0_drv.c File Reference
#include "../tca0.h"
Functions
void TCA0_Initialize (void)
Initializes the TCA0 module.
void TCA0_Deinitialize (void)
Deinitializes the TCA0 module.
void TCA0_Start (void)
Starts the TCA0.
void TCA0_Stop (void)
Stops the TCA0.
void TCA0_CounterSet (uint32_t counterValue)
Sets the counter value.
uint32_t TCA0_CounterGet (void)
Returns the current counter value.
void TCA0_PeriodSet (uint32_t periodCount)
Sets the period count value.
uint32_t TCA0_PeriodGet (void)
Returns the current period value.
uint32_t TCA0_MaxCountGet (void)
Returns the maximum count value.
ISR (TCA0_OVF_vect)
void TCA0_OverflowCallbackRegister (void(*CallbackHandler)(void))
Registers a callback function for the TCA0 overflow or underflow event.
Variables
const struct TIMER_INTERFACE myTimer
static void(* TCA0_OverflowCallback )(void) = NULL
Function Documentation
ISR()
ISR (TCA0_OVF_vect )
Variable Documentation
myTimer
const struct TIMER_INTERFACE myTimer
Initial value:
= { .Initialize = TCA0_Initialize, .Deinitialize = TCA0_Deinitialize, .Start = TCA0_Start, .Stop = TCA0_Stop, .PeriodSet = TCA0_PeriodSet, .PeriodGet = TCA0_PeriodGet, .CounterSet = TCA0_CounterSet, .CounterGet = TCA0_CounterGet, .MaxCountGet = TCA0_MaxCountGet, .TimeoutCallbackRegister = TCA0_OverflowCallbackRegister, .Tasks = NULL }
TCA0_OverflowCallback
void(* TCA0_OverflowCallback) (void) = NULL[static]
3.14.4.8.5 source/tca0_drv.h File Reference
#include <stdint.h> #include <stdbool.h> #include "../system/utils/compiler.h" #include "timer_interface.h"
Functions
void TCA0_Initialize (void)
Initializes the TCA0 module. This routine must be called before any other TCA0 routines.
void TCA0_Deinitialize (void)
Deinitializes the TCA0 module.
void TCA0_Start (void)
Starts TCA0.
void TCA0_Stop (void)
Stops TCA0.
uint32_t TCA0_CounterGet (void)
Returns the current counter value.
void TCA0_CounterSet (uint32_t counterValue)
Sets the counter value.
void TCA0_PeriodSet (uint32_t periodCount)
Sets the period count value.
uint32_t TCA0_PeriodGet (void)
Returns the current period value.
uint32_t TCA0_MaxCountGet (void)
Returns the maximum count value.
void TCA0_Tasks (void)
Performs tasks to be executed during the TCA0 overflow event.
void TCA0_OverflowCallbackRegister (void(*CallbackHandler)(void))
Registers a callback function for the TCA0 overflow event.
Macros
#define TCA0_MAX_COUNT (65535U)
Defines the maximum count of the timer.
#define TCA0_CLOCK_FREQ (1000000UL)
Defines the timer prescaled clock frequency in hertz.
#define MYTIMER_MAX_COUNT TCA0_MAX_COUNT
Defines the Custom Name for the TCA0_MAX_COUNT.
#define MYTIMER_CLOCK_FREQ TCA0_CLOCK_FREQ
Defines the Custom Name for the TCA0_CLOCK_FREQ.
#define myTimer_Initialize TCA0_Initialize
Defines the Custom Name for the TCA0_Initialize API.
#define myTimer_Deinitialize TCA0_Deinitialize
Defines the Custom Name for the TCA0_Deinitialize API.
#define myTimer_Start TCA0_Start
Defines the Custom Name for the TCA0_Start API.
#define myTimer_Stop TCA0_Stop
Defines the Custom Name for the TCA0_Stop API.
#define myTimer_CounterGet TCA0_CounterGet
Defines the Custom Name for the TCA0_CounterGet API.
#define myTimer_CounterSet TCA0_CounterSet
Defines the Custom Name for the TCA0_CounterSet API.
#define myTimer_PeriodSet TCA0_PeriodSet
Defines the Custom Name for the TCA0_PeriodSet API.
#define myTimer_PeriodGet TCA0_PeriodGet
Defines the Custom Name for the TCA0_PeriodGet API.
#define myTimer_MaxCountGet TCA0_MaxCountGet
Defines the Custom Name for the TCA0_MaxCountGet API.
#define myTimer_OverflowCallbackRegister TCA0_OverflowCallbackRegister
Defines the Custom Name for the TCA0_OverflowCallbackRegister API.
#define myTimer_Tasks TCA0_Tasks
Defines the Custom Name for the TCA0_Tasks API.
Variables
const struct TIMER_INTERFACE myTimer
Variable Documentation
myTimer
const struct TIMER_INTERFACE myTimer
3.14.4.8.6 source/tca0_split.c File Reference
#include "../tca0.h"
Functions
void TCA0_Initialize (void)
Initializes the TCA0 module.
void TCA0_Deinitialize (void)
Deinitializes the TCA0 module.
void TCA0_Start (void)
Starts the TCA0.
void TCA0_Stop (void)
Stops the TCA0.
void TCA0_LowCounterSet (uint8_t timerVal)
Sets the counter value for the Low Byte Timer.
uint8_t TCA0_LowCounterGet (void)
Returns the Low Byte Timer counter value.
void TCA0_HighCounterSet (uint8_t timerVal)
Sets the counter value for the High Byte Timer.
uint8_t TCA0_HighCounterGet (void)
Returns the High Byte Timer counter value.
void TCA0_HighPeriodSet (uint8_t periodVal)
Sets the period count value for the High Byte Timer.
void TCA0_LowPeriodSet (uint8_t periodVal)
Sets the period count value for the Low Byte Timer.
uint8_t TCA0_HighPeriodGet (void)
Returns the period count value of the High Byte Timer.
uint8_t TCA0_LowPeriodGet (void)
Returns the period count value of the Low Byte Timer.
uint8_t TCA0_MaxCountGet (void)
Returns the maximum count value.
void TCA0_HUNFInterruptFlagClear (void)
Clears the High Byte Timer Underflow Interrupt flag.
bool TCA0_HUNFInterruptStatusGet (void)
Returns the status of the High Byte Timer Underflow Interrupt flag.
void TCA0_LUNFInterruptFlagClear (void)
Clears the Low Byte Timer Underflow Interrupt flag.
bool TCA0_LUNFInterruptStatusGet (void)
Returns the status of the Low Byte Timer Underflow Interrupt flag.
void TCA0_LCMP0InterruptFlagClear (void)
Clears the Low Byte Timer Compare Channel 0 Match Interrupt flag.
bool TCA0_LCMP0InterruptStatusGet (void)
Returns the status of the Low Byte Timer Compare Channel 0 Match Interrupt flag.
void TCA0_LCMP1InterruptFlagClear (void)
Clears the Low Byte Timer Compare Channel 1 Match Interrupt flag.
bool TCA0_LCMP1InterruptStatusGet (void)
Returns the status of the Low Byte Timer Compare Channel 1 Match Interrupt flag.
void TCA0_LCMP2InterruptFlagClear (void)
Clears the Low Byte Timer Compare Channel 2 Match Interrupt flag.
bool TCA0_LCMP2InterruptStatusGet (void)
Returns the status of the Low Byte Timer Compare Channel 2 Match Interrupt flag.
void TCA0_Tasks (void)
Performs tasks to be executed during the TCA0 interrupt events.
void TCA0_HighCountCallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the High Byte Timer underflow event.
void TCA0_LowCompare0CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the Low Byte Timer Compare 0 match event.
void TCA0_LowCompare1CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the Low Byte Timer Compare 1 match event.
void TCA0_LowCompare2CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the Low Byte Timer Compare 2 match event.
void TCA0_LowCountCallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the Low Byte Timer underflow event.
Variables
static void(* TCA0_HCNT_Callback )(void) = NULL
static void(* TCA0_LCMP0_Callback )(void) = NULL
static void(* TCA0_LCMP1_Callback )(void) = NULL
static void(* TCA0_LCMP2_Callback )(void) = NULL
static void(* TCA0_LCNT_Callback )(void) = NULL
Variable Documentation
TCA0_HCNT_Callback
void(* TCA0_HCNT_Callback) (void) = NULL[static]
TCA0_LCMP0_Callback
void(* TCA0_LCMP0_Callback) (void) = NULL[static]
TCA0_LCMP1_Callback
void(* TCA0_LCMP1_Callback) (void) = NULL[static]
TCA0_LCMP2_Callback
void(* TCA0_LCMP2_Callback) (void) = NULL[static]
TCA0_LCNT_Callback
void(* TCA0_LCNT_Callback) (void) = NULL[static]
3.14.4.8.7 source/tca0_split.h File Reference
#include <stdint.h> #include <stdbool.h> #include "../system/utils/compiler.h" #include "./tca0_deprecated.h"
Functions
void TCA0_Initialize (void)
Initializes the TCA0 module.
void TCA0_Deinitialize (void)
Deinitializes the TCA0 module.
void TCA0_Start (void)
Starts the TCA0.
void TCA0_Stop (void)
Stops the TCA0.
void TCA0_LowCounterSet (uint8_t timerVal)
Sets the counter value for the Low Byte Timer.
uint8_t TCA0_LowCounterGet (void)
Returns the Low Byte Timer counter value.
uint8_t TCA0_HighCounterGet (void)
Returns the High Byte Timer counter value.
void TCA0_HighCounterSet (uint8_t timerVal)
Sets the counter value for the High Byte Timer.
void TCA0_HighPeriodSet (uint8_t periodVal)
Sets the period count value for the High Byte Timer.
void TCA0_LowPeriodSet (uint8_t periodVal)
Sets the period count value for the Low Byte Timer.
uint8_t TCA0_HighPeriodGet (void)
Returns the period count value of the High Byte Timer.
uint8_t TCA0_LowPeriodGet (void)
Returns the period count value of the Low Byte Timer.
uint8_t TCA0_MaxCountGet (void)
Returns the maximum timer count value.
void TCA0_HUNFInterruptFlagClear (void)
Clears the High Byte Timer Underflow Interrupt flag.
bool TCA0_HUNFInterruptStatusGet (void)
Returns the status of the High Byte Timer Underflow Interrupt flag.
void TCA0_LUNFInterruptFlagClear (void)
Clears the Low Byte Timer Underflow Interrupt flag.
bool TCA0_LUNFInterruptStatusGet (void)
Returns the status of the Low Byte Timer Underflow Interrupt flag.
void TCA0_LCMP0InterruptFlagClear (void)
Clears the Low Byte Timer Compare Channel 0 Match Interrupt flag.
bool TCA0_LCMP0InterruptStatusGet (void)
Returns the status of the Low Byte Timer Compare Channel 0 Match Interrupt flag.
void TCA0_LCMP1InterruptFlagClear (void)
Clears the Low Byte Timer Compare Channel 1 Match Interrupt flag.
bool TCA0_LCMP1InterruptStatusGet (void)
Returns the status of the Low Byte Timer Compare Channel 1 Match Interrupt flag.
void TCA0_LCMP2InterruptFlagClear (void)
Clears the Low Byte Timer Compare Channel 2 Match Interrupt flag.
void TCA0_InterruptEnable (void)
Enables the timer interrupts in Split mode.
void TCA0_InterruptDisable (void)
Disables the timer interrupts in Split mode.
bool TCA0_LCMP2InterruptStatusGet (void)
Returns the status of the Low Byte Timer Compare Channel 2 Match Interrupt flag.
void TCA0_HighCountCallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the High Byte Timer underflow event.
void TCA0_LowCompare0CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the Low Byte Timer Compare 0 match event.
void TCA0_LowCompare1CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the Low Byte Timer Compare 1 match event.
void TCA0_LowCompare2CallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the Low Byte Timer Compare 2 match event.
void TCA0_LowCountCallbackRegister (TCA0_cb_t CallbackHandler)
Registers a callback function for the Low Byte Timer underflow event.
void TCA0_Tasks (void)
Performs tasks to be executed during the timer interrupt events.
Macros
#define TCA0_MAX_COUNT (255U)
Defines the maximum count of the timer.
#define TCA0_CLOCK_FREQ (4000000UL)
Defines the timer prescaled clock frequency in hertz.
Typedefs
typedef void(* TCA0_cb_t) (void)
Typedef Documentation
TCA0_cb_t
typedef void(* TCA0_cb_t) (void)
3.14.4.8.8 source/tca0_split_deprecated.h File Reference
Macros
#define TCA0_ReadHighCount TCA0_HighCounterGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ReadHighCount will be deprecated in the future release. Use TCA0_HighCounterGet instead.
#define TCA0_WriteHighCount TCA0_HighCounterSet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_WriteHighCount will be deprecated in the future release. Use TCA0_HighCounterSet instead.
#define TCA0_ReadLowCount TCA0_LowCounterGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ReadLowCount will be deprecated in the future release. Use TCA0_LowCounterGet instead.
#define TCA0_WriteLowCount TCA0_LowCounterSet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_WriteLowCount will be deprecated in the future release. Use TCA0_LowCounterSet instead.
#define TCA0_ClearHUNFInterruptFlag TCA0_HUNFInterruptFlagClear
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ClearHUNFInterruptFlag will be deprecated in the future release. Use TCA0_HUNFInterruptFlagClear instead.
#define TCA0_IsHUNFInterruptFlagSet TCA0_HUNFInterruptStatusGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_IsHUNFInterruptFlagSet will be deprecated in the future release. Use TCA0_HUNFInterruptStatusGet instead.
#define TCA0_ClearLUNFInterruptFlag TCA0_LUNFInterruptFlagClear
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ClearLUNFInterruptFlag will be deprecated in the future release. Use TCA0_LUNFInterruptFlagClear instead.
#define TCA0_IsLUNFInterruptFlagSet TCA0_LUNFInterruptStatusGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_IsLUNFInterruptFlagSet will be deprecated in the future release. Use TCA0_LUNFInterruptStatusGet instead.
#define TCA0_ClearLCMP0InterruptFlag TCA0_LCMP0InterruptFlagClear
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ClearLCMP0InterruptFlag will be deprecated in the future release. Use TCA0_LCMP0InterruptFlagClear instead.
#define TCA0_IsLCMP0InterruptFlagSet TCA0_LCMP0InterruptStatusGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_IsLCMP0InterruptFlagSet will be deprecated in the future release. Use TCA0_LCMP0InterruptStatusGet instead.
#define TCA0_ClearLCMP1InterruptFlag TCA0_LCMP1InterruptFlagClear
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ClearLCMP1InterruptFlag will be deprecated in the future release. Use TCA0_LCMP1InterruptFlagClear instead.
#define TCA0_IsLCMP1InterruptFlagSet TCA0_LCMP1InterruptStatusGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_IsLCMP1InterruptFlagSet will be deprecated in the future release. Use TCA0_LCMP1InterruptStatusGet instead.
#define TCA0_ClearLCMP2InterruptFlag TCA0_LCMP2InterruptFlagClear
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_ClearHUNFInterruptFlag will be deprecated in the future release. Use TCA0_LCMP2InterruptFlagClear instead.
#define TCA0_IsLCMP2InterruptFlagSet TCA0_LCMP2InterruptStatusGet
Defines the Custom Name for the TCA0_CounterGet API. The TCA0_IsLCMP2InterruptFlagSet will be deprecated in the future release. Use TCA0_LCMP2InterruptStatusGet instead.