CMSIS-Driver_PIC32CM-PL  
Peripheral Library (PLIB) Documentation
 
Loading...
Searching...
No Matches
TC Interface

Driver API for TC (plib_tc0_timer8bit.h) More...

Data Structures

struct  TC0_8TIMER_OBJECT
 TC0 8-bit Timer object structure. More...
 

Typedefs

typedef void(* TC0_8TIMER_CALLBACK_HANDLER) (TC_INTERRUPT int_cause)
 TC0 8-bit Timer callback handler type.
 

Enumerations

enum  TC_GCLK_PRESCALER {
  TC_GCLK_PRESCALER_DIV_1 = TC_CTRLA_PRESCALER_DIV1 , TC_GCLK_PRESCALER_DIV_2 = TC_CTRLA_PRESCALER_DIV2 , TC_GCLK_PRESCALER_DIV_4 = TC_CTRLA_PRESCALER_DIV4 , TC_GCLK_PRESCALER_DIV_8 = TC_CTRLA_PRESCALER_DIV8 ,
  TC_GCLK_PRESCALER_DIV_16 = TC_CTRLA_PRESCALER_DIV16 , TC_GCLK_PRESCALER_DIV_64 = TC_CTRLA_PRESCALER_DIV64 , TC_GCLK_PRESCALER_DIV_256 = TC_CTRLA_PRESCALER_DIV256 , TC_GCLK_PRESCALER_DIV_1024 = TC_CTRLA_PRESCALER_DIV1024
}
 TC0 clock prescaler options. More...
 
enum  TC_PRESCALER_SYNC_MODE { TC_PRESCSYNC_GCLK = TC_CTRLA_PRESCSYNC_GCLK , TC_PRESCSYNC_PRESC = TC_CTRLA_PRESCSYNC_PRESC , TC_PRESCSYNC_RESYNC = TC_CTRLA_PRESCSYNC_RESYNC }
 TC0 prescaler synchronization mode. More...
 
enum  TC_WAVE_GEN_MODE { TC_WAVE_GEN_NFRQ = TC_WAVE_WAVEGEN_NFRQ , TC_WAVE_GEN_MFRQ = TC_WAVE_WAVEGEN_MFRQ , TC_WAVE_GEN_NPWM = TC_WAVE_WAVEGEN_NPWM , TC_WAVE_GEN_MPWM = TC_WAVE_WAVEGEN_MPWM }
 TC0 waveform generation mode. More...
 
enum  TC_COUNT_DIRECTION { TC_COUNT_DIRECTION_UP = 1 , TC_COUNT_DIRECTION_DOWN = 2 }
 TC0 counter direction. More...
 
enum  TC_INTERRUPT { TC_INTERRUPT_OVERFLOW = TC_INTENSET_OVF_Msk , TC_INTERRUPT_ERROR = TC_INTENSET_ERR_Msk , TC_INTERRUPT_MATCH_CAPTURE_0 = TC_INTENSET_MC0_Msk , TC_INTERRUPT_MATCH_CAPTURE_1 = TC_INTENSET_MC1_Msk }
 TC0 interrupt sources. More...
 
enum  TC_CAPTURE_CHANNEL { TC_CAPTURE_CHANNEL_0 = 0 , TC_CAPTURE_CHANNEL_1 }
 TC Capture Channel Selection. More...
 
enum  TC_COMPARE_CHANNEL { TC_COMPARE_CHANNEL_0 = 0 , TC_COMPARE_CHANNEL_1 }
 TC Compare Channel Selection. More...
 
enum  TC_EVENT_ACTION {
  TC_EVENT_ACTION_OFF = ((0x0 << TC_EVCTRL_EVACT_Pos) & TC_EVCTRL_EVACT_Msk) , TC_EVENT_ACTION_RETRIGGER = ((0x01 << TC_EVCTRL_EVACT_Pos) & TC_EVCTRL_EVACT_Msk) , TC_EVENT_ACTION_COUNT = ((0x02 << TC_EVCTRL_EVACT_Pos) & TC_EVCTRL_EVACT_Msk) , TC_EVENT_ACTION_START = ((0x03 << TC_EVCTRL_EVACT_Pos) & TC_EVCTRL_EVACT_Msk) ,
  TC_EVENT_ACTION_STAMP = ((0x04 << TC_EVCTRL_EVACT_Pos) & TC_EVCTRL_EVACT_Msk) , TC_EVENT_ACTION_PPW = ((0x05 << TC_EVCTRL_EVACT_Pos) & TC_EVCTRL_EVACT_Msk) , TC_EVENT_ACTION_PWP = ((0x06 << TC_EVCTRL_EVACT_Pos) & TC_EVCTRL_EVACT_Msk) , TC_EVENT_ACTION_PW = ((0x07 << TC_EVCTRL_EVACT_Pos) & TC_EVCTRL_EVACT_Msk)
}
 TC Event Action Selection. More...
 
enum  TC_SIGNAL_POLARITY { TC_SIGNAL_POLARITY_NON_INVERTED = 0 , TC_SIGNAL_POLARITY_INVERTED }
 TC Signal Polarity Selection. More...
 
enum  TC_CAPTURE_TRIGGER_SOURCE { TC_CAPTURE_TRIGGER_SOURCE_EVENT =0 , TC_CAPTURE_TRIGGER_SOURCE_IO }
 TC Capture Trigger Source Selection. More...
 

Functions

void TC0_SetInterruptHandler (void(*callback)(void))
 Registers the TC0 interrupt callback function. The callback function can be called from main.c for direct callback registration.
 
void TC0_TIMER_8BIT_Initialize (void)
 Initialize the TC0 8BIT timer.
 
void TC0_TIMER_8BIT_SetClockPrescaler (TC_GCLK_PRESCALER prescaler, TC_PRESCALER_SYNC_MODE presc_sync_mode)
 Set the prescaler and prescaler synchronization for TC0 8BIT.
 
void TC0_TIMER_8BIT_Enable (void)
 Enable the TC0 8BIT timer.
 
void TC0_TIMER_8BIT_Disable (void)
 Disable the TC0 8BIT timer.
 
void TC0_TIMER_8BIT_ResetSoftware (void)
 Perform a software reset of the TC0 8BIT timer.
 
void TC0_TIMER_8BIT_SetCounter (uint8_t value)
 Set the counter value.
 
uint8_t TC0_TIMER_8BIT_GetCounter (void)
 Get the current counter value.
 
void TC0_TIMER_8BIT_SetPeriod (uint8_t period)
 Set the period value.
 
uint8_t TC0_TIMER_8BIT_GetPeriod (void)
 Get the current period value.
 
void TC0_TIMER_8BIT_EnableOneShotOperation (void)
 Enable one-shot mode.
 
void TC0_TIMER_8BIT_DisableOneShotOperation (void)
 Disable one-shot mode.
 
void TC0_TIMER_8BIT_SetCounterDirection (TC_COUNT_DIRECTION direction)
 Set the counting direction for TC0.
 
void TC0_TIMER_8BIT_EnableRunOnStandby (void)
 Enable running in standby mode.
 
void TC0_TIMER_8BIT_DisableRunOnStandby (void)
 Disable running in standby mode.
 
void TC0_TIMER_8BIT_EnableClockOnDemand (void)
 Enable clock on demand.
 
void TC0_TIMER_8BIT_DisableClockOnDemand (void)
 Disable clock on demand.
 
void TC0_TIMER_8BIT_EnableInterrupt (TC_INTERRUPT source)
 Enable specific TC0 interrupts.
 
void TC0_TIMER_8BIT_DisableInterrupt (TC_INTERRUPT source)
 Disable specific TC0 interrupts.
 
void TC0_TIMER_8BIT_ClearInterruptFlag (TC_INTERRUPT flag)
 Clear specific TC0 interrupt flags.
 
void TC0_TIMER_8BIT_StopCounter (void)
 Stop the counter of the 8BIT timer.
 
void TC0_TIMER_8BIT_RetriggerCounter (void)
 Retrigger the counter of the 8BIT timer.
 
uint32_t TC0_TIMER_8BIT_GetInterruptFlag (void)
 Get the current TC0 interrupt flags.
 
void TC0_TIMER_8BIT_SetCallbackHandler (TC0_8TIMER_CALLBACK_HANDLER callback)
 Register a callback for timer interrupts.
 
bool TC0_TIMER_8BIT_CounterIsStopped (void)
 Check if the counter of the 8BIT timer is stopped.
 
void TC0_TIMER_8BIT_EnableEventOutput (void)
 Enable event output for the timer channel.
 
void TC0_TIMER_8BIT_DisableEventOutput (void)
 Disable event output for the timer channel.
 
void TC0_TIMER_8BIT_EnableInputEvent (void)
 Enable input event for the timer.
 
void TC0_TIMER_8BIT_DisableInputEvent (void)
 Disable input event for the timer.
 
void TC0_TIMER_8BIT_SetEventInputPolarity (TC_SIGNAL_POLARITY polarity)
 Set event input polarity for the timer.
 
void TC0_TIMER_8BIT_SetEventAction (TC_EVENT_ACTION action)
 Set event input action for the timer.
 

Description

Driver API for TC (plib_tc0_timer8bit.h)

Typedef Documentation

◆ TC0_8TIMER_CALLBACK_HANDLER

typedef void(* TC0_8TIMER_CALLBACK_HANDLER) (TC_INTERRUPT int_cause)

TC0 8-bit Timer callback handler type.

This typedef defines the function pointer type for a callback handler that is invoked when a TC0 8-bit timer interrupt occurs.

The callback function receives the interrupt cause as a parameter, allowing the application to handle specific timer events such as overflow, error, or match/compare interrupts.

Parameters
int_causeThe interrupt source mask of type TC_INTERRUPT.
Note
Register your callback using TC0_TIMER_8BIT_SetCallbackHandler(). The callback will be called from the TC0 interrupt handler context.

Enumeration Type Documentation

◆ TC_CAPTURE_CHANNEL

TC Capture Channel Selection.

Selects the capture channel for TC0 operations.

Enumerator
TC_CAPTURE_CHANNEL_0 

Capture Channel 0

TC_CAPTURE_CHANNEL_1 

Capture Channel 1

◆ TC_CAPTURE_TRIGGER_SOURCE

TC Capture Trigger Source Selection.

Specifies the trigger source for TC0 capture operations.

Enumerator
TC_CAPTURE_TRIGGER_SOURCE_EVENT 

Event system trigger

TC_CAPTURE_TRIGGER_SOURCE_IO 

I/O pin trigger

◆ TC_COMPARE_CHANNEL

TC Compare Channel Selection.

Selects the compare channel for TC0 operations.

Enumerator
TC_COMPARE_CHANNEL_0 

Compare Channel 0

TC_COMPARE_CHANNEL_1 

Compare Channel 1

◆ TC_COUNT_DIRECTION

TC0 counter direction.

Specifies the counting direction for the TC0 counter.

Enumerator
TC_COUNT_DIRECTION_UP 

Count up

TC_COUNT_DIRECTION_DOWN 

Count down

◆ TC_EVENT_ACTION

TC Event Action Selection.

Enumerates the available event actions for TC0 event system.

Enumerator
TC_EVENT_ACTION_OFF 

No action

TC_EVENT_ACTION_RETRIGGER 

Retrigger

TC_EVENT_ACTION_COUNT 

Count

TC_EVENT_ACTION_START 

Start

TC_EVENT_ACTION_STAMP 

Stamp

TC_EVENT_ACTION_PPW 

Period pulse width

TC_EVENT_ACTION_PWP 

Pulse width period

TC_EVENT_ACTION_PW 

Pulse width

◆ TC_GCLK_PRESCALER

TC0 clock prescaler options.

Enumerates the available clock division factors for the TC0 peripheral. Used to configure the timer/counter clock rate.

Enumerator
TC_GCLK_PRESCALER_DIV_1 

Divide by 1

TC_GCLK_PRESCALER_DIV_2 

Divide by 2

TC_GCLK_PRESCALER_DIV_4 

Divide by 4

TC_GCLK_PRESCALER_DIV_8 

Divide by 8

TC_GCLK_PRESCALER_DIV_16 

Divide by 16

TC_GCLK_PRESCALER_DIV_64 

Divide by 64

TC_GCLK_PRESCALER_DIV_256 

Divide by 256

TC_GCLK_PRESCALER_DIV_1024 

Divide by 1024

◆ TC_INTERRUPT

TC0 interrupt sources.

Enumerates the available interrupt sources for the TC0 peripheral.

Enumerator
TC_INTERRUPT_OVERFLOW 

Overflow Interrupt Mask

TC_INTERRUPT_ERROR 

Error Interrupt Mask

TC_INTERRUPT_MATCH_CAPTURE_0 

Match/Compare 0 Interrupt Mask

TC_INTERRUPT_MATCH_CAPTURE_1 

Match/Compare 1 Interrupt Mask

◆ TC_PRESCALER_SYNC_MODE

TC0 prescaler synchronization mode.

Enumerates the available synchronization modes for the TC0 prescaler. Determines how the prescaler synchronizes with the clock source.

Enumerator
TC_PRESCSYNC_GCLK 

Synchronize with GCLK

TC_PRESCSYNC_PRESC 

Synchronize with prescaler

TC_PRESCSYNC_RESYNC 

Resynchronize

◆ TC_SIGNAL_POLARITY

TC Signal Polarity Selection.

Specifies the polarity for TC0 input signals.

Enumerator
TC_SIGNAL_POLARITY_NON_INVERTED 

Non-inverted signal

TC_SIGNAL_POLARITY_INVERTED 

Inverted signal

◆ TC_WAVE_GEN_MODE

TC0 waveform generation mode.

Enumerates the available waveform generation modes for the TC0 peripheral. Used to configure timer/counter output behavior.

Enumerator
TC_WAVE_GEN_NFRQ 

Normal Frequency

TC_WAVE_GEN_MFRQ 

Match Frequency

TC_WAVE_GEN_NPWM 

Normal PWM

TC_WAVE_GEN_MPWM 

Match PWM

Function Documentation

◆ TC0_SetInterruptHandler()

void TC0_SetInterruptHandler ( void(*)(void) callback)

Registers the TC0 interrupt callback function. The callback function can be called from main.c for direct callback registration.

Parameters
[in]callbackPointer to user-defined TC0 interrupt handler function. Pass NULL to unregister any existing callback.

◆ TC0_TIMER_8BIT_ClearInterruptFlag()

void TC0_TIMER_8BIT_ClearInterruptFlag ( TC_INTERRUPT flag)

Clear specific TC0 interrupt flags.

Parameters
flagInterrupt flag mask.
Returns
None

◆ TC0_TIMER_8BIT_CounterIsStopped()

bool TC0_TIMER_8BIT_CounterIsStopped ( void )

Check if the counter of the 8BIT timer is stopped.

Parameters
None
Returns
true if the counter is stopped, false otherwise.

◆ TC0_TIMER_8BIT_Disable()

void TC0_TIMER_8BIT_Disable ( void )

Disable the TC0 8BIT timer.

Parameters
None
Returns
None

◆ TC0_TIMER_8BIT_DisableClockOnDemand()

void TC0_TIMER_8BIT_DisableClockOnDemand ( void )

Disable clock on demand.

Parameters
None
Returns
None

◆ TC0_TIMER_8BIT_DisableEventOutput()

void TC0_TIMER_8BIT_DisableEventOutput ( void )

Disable event output for the timer channel.

Parameters
channelTimer channel.
Returns
None

◆ TC0_TIMER_8BIT_DisableInputEvent()

void TC0_TIMER_8BIT_DisableInputEvent ( void )

Disable input event for the timer.

Parameters
None
Returns
None

◆ TC0_TIMER_8BIT_DisableInterrupt()

void TC0_TIMER_8BIT_DisableInterrupt ( TC_INTERRUPT source)

Disable specific TC0 interrupts.

Parameters
sourceInterrupt source mask of type TC_INTERRUPT.
Returns
None

◆ TC0_TIMER_8BIT_DisableOneShotOperation()

void TC0_TIMER_8BIT_DisableOneShotOperation ( void )

Disable one-shot mode.

Parameters
None
Returns
None

◆ TC0_TIMER_8BIT_DisableRunOnStandby()

void TC0_TIMER_8BIT_DisableRunOnStandby ( void )

Disable running in standby mode.

Parameters
None
Returns
None

◆ TC0_TIMER_8BIT_Enable()

void TC0_TIMER_8BIT_Enable ( void )

Enable the TC0 8BIT timer.

Parameters
None
Returns
None

◆ TC0_TIMER_8BIT_EnableClockOnDemand()

void TC0_TIMER_8BIT_EnableClockOnDemand ( void )

Enable clock on demand.

Parameters
None
Returns
None

◆ TC0_TIMER_8BIT_EnableEventOutput()

void TC0_TIMER_8BIT_EnableEventOutput ( void )

Enable event output for the timer channel.

Parameters
channelTimer channel (typically 0 for overflow event).
Returns
None

◆ TC0_TIMER_8BIT_EnableInputEvent()

void TC0_TIMER_8BIT_EnableInputEvent ( void )

Enable input event for the timer.

Parameters
None
Returns
None

◆ TC0_TIMER_8BIT_EnableInterrupt()

void TC0_TIMER_8BIT_EnableInterrupt ( TC_INTERRUPT source)

Enable specific TC0 interrupts.

Parameters
sourceInterrupt source mask of type TC_INTERRUPT.
Returns
None

◆ TC0_TIMER_8BIT_EnableOneShotOperation()

void TC0_TIMER_8BIT_EnableOneShotOperation ( void )

Enable one-shot mode.

Parameters
None
Returns
None

◆ TC0_TIMER_8BIT_EnableRunOnStandby()

void TC0_TIMER_8BIT_EnableRunOnStandby ( void )

Enable running in standby mode.

Parameters
None
Returns
None

◆ TC0_TIMER_8BIT_GetCounter()

uint8_t TC0_TIMER_8BIT_GetCounter ( void )

Get the current counter value.

Parameters
None
Returns
Counter value.

◆ TC0_TIMER_8BIT_GetInterruptFlag()

uint32_t TC0_TIMER_8BIT_GetInterruptFlag ( void )

Get the current TC0 interrupt flags.

Parameters
None
Returns
Interrupt flag mask.

◆ TC0_TIMER_8BIT_GetPeriod()

uint8_t TC0_TIMER_8BIT_GetPeriod ( void )

Get the current period value.

Parameters
None
Returns
Period value.

◆ TC0_TIMER_8BIT_Initialize()

void TC0_TIMER_8BIT_Initialize ( void )

Initialize the TC0 8BIT timer.

Parameters
None
Returns
None

◆ TC0_TIMER_8BIT_ResetSoftware()

void TC0_TIMER_8BIT_ResetSoftware ( void )

Perform a software reset of the TC0 8BIT timer.

Parameters
None
Returns
None

◆ TC0_TIMER_8BIT_RetriggerCounter()

void TC0_TIMER_8BIT_RetriggerCounter ( void )

Retrigger the counter of the 8BIT timer.

Parameters
None
Returns
None

◆ TC0_TIMER_8BIT_SetCallbackHandler()

void TC0_TIMER_8BIT_SetCallbackHandler ( TC0_8TIMER_CALLBACK_HANDLER callback)

Register a callback for timer interrupts.

Parameters
callbackFunction pointer to callback.
Returns
None

◆ TC0_TIMER_8BIT_SetClockPrescaler()

void TC0_TIMER_8BIT_SetClockPrescaler ( TC_GCLK_PRESCALER prescaler,
TC_PRESCALER_SYNC_MODE presc_sync_mode )

Set the prescaler and prescaler synchronization for TC0 8BIT.

Parameters
prescalerPrescaler value.
prescsyncPrescaler synchronization value.
Returns
None

◆ TC0_TIMER_8BIT_SetCounter()

void TC0_TIMER_8BIT_SetCounter ( uint8_t value)

Set the counter value.

Parameters
valueCounter value to set.
Returns
None

◆ TC0_TIMER_8BIT_SetCounterDirection()

void TC0_TIMER_8BIT_SetCounterDirection ( TC_COUNT_DIRECTION direction)

Set the counting direction for TC0.

Parameters
directionTC_COUNT_DIRECTION_UP or TC_COUNT_DIRECTION_DOWN.
Returns
None

◆ TC0_TIMER_8BIT_SetEventAction()

void TC0_TIMER_8BIT_SetEventAction ( TC_EVENT_ACTION action)

Set event input action for the timer.

Parameters
actionEvent action (e.g., retrigger, start).
Returns
None

◆ TC0_TIMER_8BIT_SetEventInputPolarity()

void TC0_TIMER_8BIT_SetEventInputPolarity ( TC_SIGNAL_POLARITY polarity)

Set event input polarity for the timer.

Parameters
polaritySignal polarity (normal or inverted).
Returns
None

◆ TC0_TIMER_8BIT_SetPeriod()

void TC0_TIMER_8BIT_SetPeriod ( uint8_t period)

Set the period value.

Parameters
periodPeriod value to set.
Returns
None

◆ TC0_TIMER_8BIT_StopCounter()

void TC0_TIMER_8BIT_StopCounter ( void )

Stop the counter of the 8BIT timer.

Parameters
None
Returns
None