MTB CAT1 Peripheral driver library
Run-time Configuration Functions

General Description

This set of functions allows changes to the SAR configuration after initialization.

Functions

void Cy_SAR_SetConvertMode (SAR_Type *base, cy_en_sar_sample_ctrl_trigger_mode_t mode)
 Set the mode in which conversions are triggered. More...
 
__STATIC_INLINE void Cy_SAR_SetChanMask (SAR_Type *base, uint32_t enableMask)
 Set the enable/disable mask for the channels. More...
 
void Cy_SAR_SetLowLimit (SAR_Type *base, uint32_t lowLimit)
 Set the low threshold for range detection. More...
 
void Cy_SAR_SetHighLimit (SAR_Type *base, uint32_t highLimit)
 Set the high threshold for range detection. More...
 
__STATIC_INLINE void Cy_SAR_SetRangeCond (SAR_Type *base, cy_en_sar_range_detect_condition_t cond)
 Set the condition in which range detection interrupts are triggered. More...
 

Function Documentation

◆ Cy_SAR_SetConvertMode()

void Cy_SAR_SetConvertMode ( SAR_Type base,
cy_en_sar_sample_ctrl_trigger_mode_t  mode 
)

Set the mode in which conversions are triggered.

This function does not start any conversions; it only configures the mode for subsequent conversions.

There are three modes:

  • firmware only; hardware triggering is disabled
  • firmware and edge sensitive hardware triggering
  • firmware and level sensitive hardware triggering

Note that firmware triggering is always enabled.

Parameters
basePointer to structure describing registers
modeA value of the enum cy_en_sar_sample_ctrl_trigger_mode_t
Returns
None
Function Usage
/* Scenario: Allow a rising edge on a hardware trigger signal to initiate
* a single conversion. FW triggering is still supported. The trigger signal
* can come from a device pin or an internal block. Make sure route the hardware signal
* to the SAR trigger input. */

◆ Cy_SAR_SetChanMask()

__STATIC_INLINE void Cy_SAR_SetChanMask ( SAR_Type base,
uint32_t  enableMask 
)

Set the enable/disable mask for the channels.

Parameters
basePointer to structure describing registers
enableMaskChannel enable/disable mask. Each bit corresponds to a channel.
  • 0: the corresponding channel is disabled.
  • 1: the corresponding channel is enabled; it will be included in the next scan.
Returns
None
Function Usage
/* Scenario: Channels 0 and 1 have been configured during initialization.
* Channel 1 only needs to be scanned periodically. Disable it and only scan channel 0. */
Cy_SAR_SetChanMask(SAR_HW, 1UL);

◆ Cy_SAR_SetLowLimit()

void Cy_SAR_SetLowLimit ( SAR_Type base,
uint32_t  lowLimit 
)

Set the low threshold for range detection.

The values are interpreted as signed or unsigned according to the channel configuration. Range detection is done on the value stored in the result register. That is, after averaging, shifting sign extension, and left/right alignment.

Parameters
basePointer to structure describing registers
lowLimitThe low threshold for range detection
Returns
None
Function Usage
/* Scenario: Range detection interrupts have been enabled for all unsigned channels.
* Adjust the the low limit of the range detection to 0x300 and the high limit to 0xC00. */
Cy_SAR_SetLowLimit(SAR_HW, 0x300UL);
Cy_SAR_SetHighLimit(SAR_HW, 0xC00UL);

◆ Cy_SAR_SetHighLimit()

void Cy_SAR_SetHighLimit ( SAR_Type base,
uint32_t  highLimit 
)

Set the high threshold for range detection.

The values are interpreted as signed or unsigned according to the channel configuration. Range detection is done on the value stored in the result register. That is, after averaging, shifting sign extension, and left/right alignment.

Parameters
basePointer to structure describing registers
highLimitThe high threshold for range detection
Returns
None
Function Usage
/* Scenario: Range detection interrupts have been enabled for all unsigned channels.
* Adjust the the low limit of the range detection to 0x300 and the high limit to 0xC00. */
Cy_SAR_SetLowLimit(SAR_HW, 0x300UL);
Cy_SAR_SetHighLimit(SAR_HW, 0xC00UL);

◆ Cy_SAR_SetRangeCond()

__STATIC_INLINE void Cy_SAR_SetRangeCond ( SAR_Type base,
cy_en_sar_range_detect_condition_t  cond 
)

Set the condition in which range detection interrupts are triggered.

Parameters
basePointer to structure describing registers
condA value of the enum cy_en_sar_range_detect_condition_t.
Returns
None
Function Usage
/* Scenario: Range detection interrupts have been enabled for all unsigned channels.
* Set the range condition to be outside; a range interrupt is detected
* when (result < lowLimit) || (highLimit <= result). */