CC26xx Driver Library
[aux_compa.h] AUX continous-time comparator COMPA

Functions

static void AUXCOMPADisable (void)
 Disables COMPA. More...
 
static void AUXCOMPAEnable (void)
 Enables COMPA. More...
 
static void AUXCOMPASelectGpioInput (uint8_t auxio)
 Selects an AUXIO pin as analog input of COMPA. More...
 
static void AUXCOMPASelectGpioRef (uint8_t auxio)
 Selects an AUXIO pin as analog reference of COMPA. More...
 
void AUXCOMPASelectDacRef (void)
 Selects the DAC output as analog reference of COMPA. More...
 
void AUXCOMPASelectInternalRef (uint8_t internalRef)
 Selects an internal voltage as analog reference of COMPA. More...
 
static void AUXCOMPAIntSetPolarity (uint8_t polarity)
 Selects the edge polarity of COMPA output on which an interrupt is triggered. More...
 
static void AUXCOMPAIntClear (void)
 Clears COMPA's interrupt flag. More...
 
static void AUXCOMPAIntRegister (uint8_t polarity, void(*fnHandler)(void))
 Registers an interrupt handler on COMPA output trigger. More...
 
static void AUXCOMPAIntUnregister (void)
 Disables and unregisters the interrupt handler on COMPA output trigger. More...
 

Detailed Description

Introduction

The COMPA module provides the low-level APIs to manage the high-performance continuous-time comparator located in the AUX domain.

The COMPA driverlib module supports the following features:

COMPA supports the following inputs:

The COMPA driverlib module has the following limitation:

COMPA output is routed to the event bus where it holds a dedicated interrupt line.

On devices equipped with sensor controller, a CPU application that uses COMPA must configure ownership of the module through AUX hardware semaphores. When using the DAC as reference, ownership of both DAC and COMPA modules is required. The table below shows the conventional matching between AUX semaphores IDs and AUX peripherals:

SMPH_ID Resource Allocation
1 TDC
2 ADC + COMPB
3 COMPA + ISRC
4 Reference DAC
5 Timer2
6 Unassigned by TI
7 Unassigned by TI

COMPA operations are tightly integrated with the reference DAC present in the AUX domain, which can be connected to the reference input of COMPA. When using the DAC as reference for COMPA, it is discouraged to use the RTOS-based DAC driver. The RTOS-based DAC driver has been designed to support the specific use case of driving external loads, therefore it is not compatible with the COMPA driverlib module. When using the DAC as reference for COMPA, use the DAC driverlib module instead, which provides more flexibility and can adapt to this particular use case.

Code example

The following code example demonstrates how to set up COMPA with:

Function Documentation

§ AUXCOMPADisable()

static void AUXCOMPADisable ( void  )
inlinestatic

Disables COMPA.

This function disables COMPA and it must be called before re-enabling the module using AUXCOMPAEnable().

139 {
140  ADI8BitsClear(AUX_ADI4_BASE, ADI_4_AUX_O_COMP, ADI_4_AUX_COMP_COMPA_EN_M);
141 }
static void ADI8BitsClear(uint32_t ui32Base, uint32_t ui32Reg, uint8_t ui8Val)
Clear specific bits in an 8 bit ADI register.
Definition: adi.h:512
Here is the call graph for this function:

§ AUXCOMPAEnable()

static void AUXCOMPAEnable ( void  )
inlinestatic

Enables COMPA.

This function enables COMPA. This function must be called after having selected an input and reference for COMPA.

152 {
153  ADI8BitsSet(AUX_ADI4_BASE, ADI_4_AUX_O_COMP, ADI_4_AUX_COMP_COMPA_EN_M);
154 }
static void ADI8BitsSet(uint32_t ui32Base, uint32_t ui32Reg, uint8_t ui8Val)
Set specific bits in a single 8 bit ADI register.
Definition: adi.h:371
Here is the call graph for this function:

§ AUXCOMPAIntClear()

static void AUXCOMPAIntClear ( void  )
inlinestatic

Clears COMPA's interrupt flag.

This function clears the interrupt flag related to the COMPA interrupt line. This function should be called inside the ISR registered with AUXCOMPAIntRegister().

Referenced by AUXCOMPAIntRegister().

288 {
289  // Clear interrupt flag for AUX_COMPA
290  HWREG(AUX_EVCTL_BASE + AUX_EVCTL_O_EVTOMCUFLAGSCLR) = AUX_EVCTL_EVTOMCUFLAGSCLR_AUX_COMPA;
291 }

§ AUXCOMPAIntRegister()

static void AUXCOMPAIntRegister ( uint8_t  polarity,
void(*)(void)  fnHandler 
)
inlinestatic

Registers an interrupt handler on COMPA output trigger.

This function registers an interrupt handler and enables the AUX_COMPA interrupt line. Before enabling the interrupt line the function:

  • sets whether the interrupt should trigger on a rising or falling edge of COMPA output
  • clears the flag of the AUX_COMPA interrupt line After enabling COMPA using AUXCOMPAEnable() and before registering an interrupt using AUXCOMPAIntRegister(), a delay of at least 10us is required to let COMPA output stabilize. This allows to avoid incorrect interrupt triggers in the brief interval following the enablement of COMPA.
Parameters
polarityEdge polarity of COMPA output on which the interrupt is triggered:
fnHandlerInterrupt handler invoked when COMPA output triggers with the specified edge polarity
317 {
318  AUXCOMPAIntSetPolarity(polarity);
319 
320  // Register the interrupt handler for AUX_COMPA
321  IntRegister(INT_AUX_COMPA, fnHandler);
322 
323  // Clear any pending interrupt
325 
326  // Enable the AUX_COMPA interrupt.
327  IntEnable(INT_AUX_COMPA);
328 }
static void AUXCOMPAIntSetPolarity(uint8_t polarity)
Selects the edge polarity of COMPA output on which an interrupt is triggered.
Definition: aux_compa.h:264
static void AUXCOMPAIntClear(void)
Clears COMPA's interrupt flag.
Definition: aux_compa.h:287
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
Registers a function as an interrupt handler in the dynamic vector table.
Definition: interrupt.c:151
void IntEnable(uint32_t ui32Interrupt)
Enables an interrupt or system exception.
Definition: interrupt.c:281
Here is the call graph for this function:

§ AUXCOMPAIntSetPolarity()

static void AUXCOMPAIntSetPolarity ( uint8_t  polarity)
inlinestatic

Selects the edge polarity of COMPA output on which an interrupt is triggered.

This function selects whether a rising or falling edge of COMPA output will trigger an interrupt on the COMPA hw interrupt line. This function is called inside AUXCOMPAIntRegister() before registering the handler and enabling the interrupt line.

Parameters
polarityEdge polarity of COMPA output on which the interrupt is triggered:

Referenced by AUXCOMPAIntRegister().

265 {
266  if (polarity == AUXCOMPA_POL_RISE)
267  {
268  // Clear bit in case RISE edge is selected
269  HWREGB(AUX_EVCTL_BASE + AUX_EVCTL_O_EVTOMCUPOL) &= ~(1 << AUX_EVCTL_EVTOMCUPOL_AUX_COMPA_S);
270  }
271  else
272  {
273  // Set bit in case FALL edge is selected
274  HWREGB(AUX_EVCTL_BASE + AUX_EVCTL_O_EVTOMCUPOL) |= (1 << AUX_EVCTL_EVTOMCUPOL_AUX_COMPA_S);
275  }
276 }
#define AUXCOMPA_POL_RISE
Definition: aux_compa.h:121

§ AUXCOMPAIntUnregister()

static void AUXCOMPAIntUnregister ( void  )
inlinestatic

Disables and unregisters the interrupt handler on COMPA output trigger.

This function disables interrupts on the AUX_COMPA line, and unregister a previously set interrupt handler. Note that this function does not clear COMPA's interrupt flag. The interrupt flag is either cleared implicitly when calling AUXCOMPAIntRegister() or explicitly with AUXCOMPAIntClear().

342 {
343  // Disable the AUX_COMPA interrupt
344  IntDisable(INT_AUX_COMPA);
345 
346  // Unregister the interrupt handler for AUX_COMPA
347  IntUnregister(INT_AUX_COMPA);
348 }
void IntUnregister(uint32_t ui32Interrupt)
Unregisters an interrupt handler in the dynamic vector table.
Definition: interrupt.c:187
void IntDisable(uint32_t ui32Interrupt)
Disables an interrupt or system exception.
Definition: interrupt.c:325
Here is the call graph for this function:

§ AUXCOMPASelectDacRef()

void AUXCOMPASelectDacRef ( void  )

Selects the DAC output as analog reference of COMPA.

This function selects the reference DAC output as analog reference for COMPA. The function makes sure that any previously connected reference is disconnected from the COMPA_REF line, before connecting the DAC reference. This function must be called before enabling COMPA using AUXCOMPAEnable().

Referenced by AUXCOMPASelectGpioRef().

63  {
64  uint32_t dacCtl;
65 
66  // Use the "Not Connected" output as an intermediate step when changing DAC_VOUT_SEL
67  HWREG(AUX_ANAIF_BASE + AUX_ANAIF_O_DACCTL) &= ~AUX_ANAIF_DACCTL_DAC_VOUT_SEL_M;
68 
69  // Ensure that no internal voltages are connected to the reference voltage
70  // of COMPA and that the DAC is not driving an external pin.
71  ADI8BitsClear(AUX_ADI4_BASE, ADI_4_AUX_O_MUX0, ADI_4_AUX_MUX0_COMPA_REF_M);
72  ADI8RegWrite(AUX_ADI4_BASE, ADI_4_AUX_O_MUX4, ADI_4_AUX_MUX4_COMPA_REF_NC);
73 
74  // Disable DAC buffer when driving an internal load
75  HWREG(AUX_ANAIF_BASE + AUX_ANAIF_O_DACCTL) &= ~AUX_ANAIF_DACCTL_DAC_BUFFER_EN_M;
76 
77  // Connect the DAC output to the reference voltage of COMPA
78  dacCtl = HWREG(AUX_ANAIF_BASE + AUX_ANAIF_O_DACCTL);
79  HWREG(AUX_ANAIF_BASE + AUX_ANAIF_O_DACCTL) = (dacCtl & ~AUX_ANAIF_DACCTL_DAC_VOUT_SEL_M) | \
80  AUX_ANAIF_DACCTL_DAC_VOUT_SEL_COMPA_REF;
81 }
static void ADI8BitsClear(uint32_t ui32Base, uint32_t ui32Reg, uint8_t ui8Val)
Clear specific bits in an 8 bit ADI register.
Definition: adi.h:512
static void ADI8RegWrite(uint32_t ui32Base, uint32_t ui32Reg, uint8_t ui8Val)
Write an 8 bit value to a register in an ADI slave.
Definition: adi.h:147
Here is the call graph for this function:

§ AUXCOMPASelectGpioInput()

static void AUXCOMPASelectGpioInput ( uint8_t  auxio)
inlinestatic

Selects an AUXIO pin as analog input of COMPA.

This function selects one the available AUXIOs as analog input for COMPA. This function must be called before enabling COMPA using AUXCOMPAEnable().

Parameters
auxioCOMPA analog input:
177 {
178  ADI8RegWrite(AUX_ADI4_BASE, ADI_4_AUX_O_MUX1, auxio);
179 }
static void ADI8RegWrite(uint32_t ui32Base, uint32_t ui32Reg, uint8_t ui8Val)
Write an 8 bit value to a register in an ADI slave.
Definition: adi.h:147
Here is the call graph for this function:

§ AUXCOMPASelectGpioRef()

static void AUXCOMPASelectGpioRef ( uint8_t  auxio)
inlinestatic

Selects an AUXIO pin as analog reference of COMPA.

This function selects one of the available AUXIOs as analog reference for COMPA. The function makes sure that any previously connected reference is disconnected from the COMPA_REF line, before connecting the AUXIO reference. This function must be called before enabling COMPA using AUXCOMPAEnable().

Parameters
auxioCOMPA external analog reference:
204 {
205  // Ensure that the DAC output is not connected to COMPA reference
206  HWREG(AUX_ANAIF_BASE + AUX_ANAIF_O_DACCTL) &= ~AUX_ANAIF_DACCTL_DAC_VOUT_SEL_M;
207 
208  // Ensure that no internal voltages are connected to the reference voltage of COMPA
209  ADI8BitsClear(AUX_ADI4_BASE, ADI_4_AUX_O_MUX0, ADI_4_AUX_MUX0_COMPA_REF_M);
210 
211  // Select external reference voltage for COMPA
212  ADI8RegWrite(AUX_ADI4_BASE, ADI_4_AUX_O_MUX4, auxio);
213 }
static void ADI8BitsClear(uint32_t ui32Base, uint32_t ui32Reg, uint8_t ui8Val)
Clear specific bits in an 8 bit ADI register.
Definition: adi.h:512
static void ADI8RegWrite(uint32_t ui32Base, uint32_t ui32Reg, uint8_t ui8Val)
Write an 8 bit value to a register in an ADI slave.
Definition: adi.h:147
Here is the call graph for this function:

§ AUXCOMPASelectInternalRef()

void AUXCOMPASelectInternalRef ( uint8_t  internalRef)

Selects an internal voltage as analog reference of COMPA.

This function selects one of the available internal voltages as analog reference for COMPA. The function makes sure that any previously connected reference is disconnected from the COMPA_REF line, before connecting the internal voltage reference. This function must be called before enabling COMPA using AUXCOMPAEnable().

Parameters
internalRefCOMPA internal analog reference:

Referenced by AUXCOMPASelectGpioRef().

47 {
48  // Ensure that the DAC output is not connected to COMPA reference
49  HWREG(AUX_ANAIF_BASE + AUX_ANAIF_O_DACCTL) &= ~AUX_ANAIF_DACCTL_DAC_VOUT_SEL_M;
50 
51  // Ensure that no AUXIO pins are connected to COMPA's reference voltage
52  ADI8RegWrite(AUX_ADI4_BASE, ADI_4_AUX_O_MUX4, ADI_4_AUX_MUX4_COMPA_REF_NC);
53 
54  // Select Internal reference voltage for COMPA
55  ADI8SetValBit(AUX_ADI4_BASE, ADI_4_AUX_O_MUX0, ADI_4_AUX_MUX0_COMPA_REF_M, internalRef);
56 }
static void ADI8RegWrite(uint32_t ui32Base, uint32_t ui32Reg, uint8_t ui8Val)
Write an 8 bit value to a register in an ADI slave.
Definition: adi.h:147
static void ADI8SetValBit(uint32_t ui32Base, uint32_t ui32Reg, uint16_t ui16Mask, uint16_t ui16Val)
Set a value on any bits inside an 8 bit register in the ADI slave.
Definition: adi.h:704
Here is the call graph for this function:

Macro Definition Documentation

§ AUXCOMPA_GPIO_IN_AUX19

#define AUXCOMPA_GPIO_IN_AUX19   ADI_4_AUX_MUX1_COMPA_IN_AUXIO19

§ AUXCOMPA_GPIO_IN_AUX20

#define AUXCOMPA_GPIO_IN_AUX20   ADI_4_AUX_MUX1_COMPA_IN_AUXIO20

§ AUXCOMPA_GPIO_IN_AUX21

#define AUXCOMPA_GPIO_IN_AUX21   ADI_4_AUX_MUX1_COMPA_IN_AUXIO21

§ AUXCOMPA_GPIO_IN_AUX22

#define AUXCOMPA_GPIO_IN_AUX22   ADI_4_AUX_MUX1_COMPA_IN_AUXIO22

§ AUXCOMPA_GPIO_IN_AUX23

#define AUXCOMPA_GPIO_IN_AUX23   ADI_4_AUX_MUX1_COMPA_IN_AUXIO23

§ AUXCOMPA_GPIO_IN_AUX24

#define AUXCOMPA_GPIO_IN_AUX24   ADI_4_AUX_MUX1_COMPA_IN_AUXIO24

§ AUXCOMPA_GPIO_IN_AUX25

#define AUXCOMPA_GPIO_IN_AUX25   ADI_4_AUX_MUX1_COMPA_IN_AUXIO25

§ AUXCOMPA_GPIO_IN_AUX26

#define AUXCOMPA_GPIO_IN_AUX26   ADI_4_AUX_MUX1_COMPA_IN_AUXIO26

§ AUXCOMPA_GPIO_IN_NC

#define AUXCOMPA_GPIO_IN_NC   ADI_4_AUX_MUX1_COMPA_IN_NC

§ AUXCOMPA_GPIO_REF_AUX19

#define AUXCOMPA_GPIO_REF_AUX19   ADI_4_AUX_MUX4_COMPA_REF_AUXIO19

§ AUXCOMPA_GPIO_REF_AUX20

#define AUXCOMPA_GPIO_REF_AUX20   ADI_4_AUX_MUX4_COMPA_REF_AUXIO20

§ AUXCOMPA_GPIO_REF_AUX21

#define AUXCOMPA_GPIO_REF_AUX21   ADI_4_AUX_MUX4_COMPA_REF_AUXIO21

§ AUXCOMPA_GPIO_REF_AUX22

#define AUXCOMPA_GPIO_REF_AUX22   ADI_4_AUX_MUX4_COMPA_REF_AUXIO22

§ AUXCOMPA_GPIO_REF_AUX23

#define AUXCOMPA_GPIO_REF_AUX23   ADI_4_AUX_MUX4_COMPA_REF_AUXIO23

§ AUXCOMPA_GPIO_REF_AUX24

#define AUXCOMPA_GPIO_REF_AUX24   ADI_4_AUX_MUX4_COMPA_REF_AUXIO24

§ AUXCOMPA_GPIO_REF_AUX25

#define AUXCOMPA_GPIO_REF_AUX25   ADI_4_AUX_MUX4_COMPA_REF_AUXIO25

§ AUXCOMPA_GPIO_REF_AUX26

#define AUXCOMPA_GPIO_REF_AUX26   ADI_4_AUX_MUX4_COMPA_REF_AUXIO26

§ AUXCOMPA_GPIO_REF_NC

#define AUXCOMPA_GPIO_REF_NC   ADI_4_AUX_MUX4_COMPA_REF_NC

§ AUXCOMPA_INT_REF_ADCVREFP

#define AUXCOMPA_INT_REF_ADCVREFP   ADI_4_AUX_MUX0_COMPA_REF_ADCVREFP

§ AUXCOMPA_INT_REF_DCOUPL

#define AUXCOMPA_INT_REF_DCOUPL   ADI_4_AUX_MUX0_COMPA_REF_DCOUPL

§ AUXCOMPA_INT_REF_NC

#define AUXCOMPA_INT_REF_NC   ADI_4_AUX_MUX0_COMPA_REF_NC

§ AUXCOMPA_INT_REF_VDDS

#define AUXCOMPA_INT_REF_VDDS   ADI_4_AUX_MUX0_COMPA_REF_VDDS

§ AUXCOMPA_INT_REF_VSS

#define AUXCOMPA_INT_REF_VSS   ADI_4_AUX_MUX0_COMPA_REF_VSS

§ AUXCOMPA_POL_FALL

#define AUXCOMPA_POL_FALL   0x01

§ AUXCOMPA_POL_RISE

#define AUXCOMPA_POL_RISE   0x00

Referenced by AUXCOMPAIntSetPolarity().