M480 BSP  V3.05.001
The Board Support Package for M480 Series
Macros | Functions
DAC Exported Functions

Macros

#define DAC_START_CONV(dac)
 Start the D/A conversion. More...
 
#define DAC_ENABLE_LEFT_ALIGN(dac)
 Enable DAC data left-aligned. More...
 
#define DAC_ENABLE_RIGHT_ALIGN(dac)
 Enable DAC data right-aligned. More...
 
#define DAC_ENABLE_BYPASS_BUFFER(dac)
 Enable output voltage buffer. More...
 
#define DAC_DISABLE_BYPASS_BUFFER(dac)
 Disable output voltage buffer. More...
 
#define DAC_ENABLE_INT(dac, u32Ch)
 Enable the interrupt. More...
 
#define DAC_DISABLE_INT(dac, u32Ch)
 Disable the interrupt. More...
 
#define DAC_ENABLE_DMAUDR_INT(dac)
 Enable DMA under-run interrupt. More...
 
#define DAC_DISABLE_DMAUDR_INT(dac)
 Disable DMA under-run interrupt. More...
 
#define DAC_ENABLE_PDMA(dac)
 Enable PDMA mode. More...
 
#define DAC_DISABLE_PDMA(dac)
 Disable PDMA mode. More...
 
#define DAC_WRITE_DATA(dac, u32Ch, u32Data)
 Write data for conversion. More...
 
#define DAC_READ_DATA(dac, u32Ch)
 Read DAC 12-bit holding data. More...
 
#define DAC_IS_BUSY(dac, u32Ch)
 Get the busy state of DAC. More...
 
#define DAC_GET_INT_FLAG(dac, u32Ch)
 Get the interrupt flag. More...
 
#define DAC_GET_DMAUDR_FLAG(dac)
 Get the DMA under-run flag. More...
 
#define DAC_CLR_INT_FLAG(dac, u32Ch)
 This macro clear the interrupt status bit. More...
 
#define DAC_CLR_DMAUDR_FLAG(dac)
 This macro clear the DMA under-run flag. More...
 
#define DAC_ENABLE_GROUP_MODE(dac)
 Enable DAC group mode. More...
 
#define DAC_DISABLE_GROUP_MODE(dac)
 Disable DAC group mode. More...
 

Functions

void DAC_Open (DAC_T *dac, uint32_t u32Ch, uint32_t u32TrgSrc)
 This function make DAC module be ready to convert. More...
 
void DAC_Close (DAC_T *dac, uint32_t u32Ch)
 Disable DAC analog power. More...
 
uint32_t DAC_SetDelayTime (DAC_T *dac, uint32_t u32Delay)
 Set delay time for DAC to become stable. More...
 

Detailed Description

Macro Definition Documentation

◆ DAC_CLR_DMAUDR_FLAG

#define DAC_CLR_DMAUDR_FLAG (   dac)

This macro clear the DMA under-run flag.

Parameters
[in]dacBase address of DAC module.
Returns
None

User writes DMAUDR bit (DAC_STATUS[1]) to clear DMA under-run flag.

Definition at line 234 of file dac.h.

◆ DAC_CLR_INT_FLAG

#define DAC_CLR_INT_FLAG (   dac,
  u32Ch 
)

This macro clear the interrupt status bit.

Parameters
[in]dacBase address of DAC module.
[in]u32ChNot used in M480 DAC.
Returns
None

User writes FINISH bit (DAC_STATUS[0]) to clear DAC conversion complete finish flag.

Definition at line 225 of file dac.h.

◆ DAC_DISABLE_BYPASS_BUFFER

#define DAC_DISABLE_BYPASS_BUFFER (   dac)

Disable output voltage buffer.

Parameters
[in]dacBase address of DAC module.
Returns
None

This macro is used to disable output voltage buffer.

Definition at line 105 of file dac.h.

◆ DAC_DISABLE_DMAUDR_INT

#define DAC_DISABLE_DMAUDR_INT (   dac)

Disable DMA under-run interrupt.

Parameters
[in]dacBase address of DAC module.
Returns
None

This macro is used to disable DMA under-run interrupt.

Definition at line 143 of file dac.h.

◆ DAC_DISABLE_GROUP_MODE

#define DAC_DISABLE_GROUP_MODE (   dac)

Disable DAC group mode.

Parameters
[in]dacBase address of DAC module.
Returns
None

Definition at line 251 of file dac.h.

◆ DAC_DISABLE_INT

#define DAC_DISABLE_INT (   dac,
  u32Ch 
)

Disable the interrupt.

Parameters
[in]dacBase address of DAC module.
[in]u32ChNot used in M480 DAC.
Returns
None

This macro is used to disable DAC interrupt.

Definition at line 125 of file dac.h.

◆ DAC_DISABLE_PDMA

#define DAC_DISABLE_PDMA (   dac)

Disable PDMA mode.

Parameters
[in]dacBase address of DAC module.
Returns
None

This macro is used to disable DMA mode.

Definition at line 161 of file dac.h.

◆ DAC_ENABLE_BYPASS_BUFFER

#define DAC_ENABLE_BYPASS_BUFFER (   dac)

Enable output voltage buffer.

Parameters
[in]dacBase address of DAC module.
Returns
None

The DAC integrates a voltage output buffer that can be used to reduce output impedance and drive external loads directly without having to add an external operational amplifier.

Definition at line 96 of file dac.h.

◆ DAC_ENABLE_DMAUDR_INT

#define DAC_ENABLE_DMAUDR_INT (   dac)

Enable DMA under-run interrupt.

Parameters
[in]dacBase address of DAC module.
Returns
None

This macro is used to enable DMA under-run interrupt.

Definition at line 134 of file dac.h.

◆ DAC_ENABLE_GROUP_MODE

#define DAC_ENABLE_GROUP_MODE (   dac)

Enable DAC group mode.

Parameters
[in]dacBase address of DAC module.
Returns
None

Definition at line 243 of file dac.h.

◆ DAC_ENABLE_INT

#define DAC_ENABLE_INT (   dac,
  u32Ch 
)

Enable the interrupt.

Parameters
[in]dacBase address of DAC module.
[in]u32ChNot used in M480 DAC.
Returns
None

This macro is used to enable DAC interrupt.

Definition at line 115 of file dac.h.

◆ DAC_ENABLE_LEFT_ALIGN

#define DAC_ENABLE_LEFT_ALIGN (   dac)

Enable DAC data left-aligned.

Parameters
[in]dacBase address of DAC module.
Returns
None

User has to load data into DAC_DAT[15:4] bits. DAC_DAT[31:16] and DAC_DAT[3:0] are ignored in DAC conversion.

Definition at line 77 of file dac.h.

◆ DAC_ENABLE_PDMA

#define DAC_ENABLE_PDMA (   dac)

Enable PDMA mode.

Parameters
[in]dacBase address of DAC module.
Returns
None

DAC DMA request is generated when a hardware trigger event occurs while DMAEN (DAC_CTL[2]) is set.

Definition at line 152 of file dac.h.

◆ DAC_ENABLE_RIGHT_ALIGN

#define DAC_ENABLE_RIGHT_ALIGN (   dac)

Enable DAC data right-aligned.

Parameters
[in]dacBase address of DAC module.
Returns
None

User has to load data into DAC_DAT[11:0] bits, DAC_DAT[31:12] are ignored in DAC conversion.

Definition at line 86 of file dac.h.

◆ DAC_GET_DMAUDR_FLAG

#define DAC_GET_DMAUDR_FLAG (   dac)

Get the DMA under-run flag.

Parameters
[in]dacBase address of DAC module.
Return values
0No DMA under-run error condition occurred.
1DMA under-run error condition occurred.

This macro is used to read DMAUDR bit (DAC_STATUS[1]) to get DMA under-run state.

Definition at line 215 of file dac.h.

◆ DAC_GET_INT_FLAG

#define DAC_GET_INT_FLAG (   dac,
  u32Ch 
)

Get the interrupt flag.

Parameters
[in]dacBase address of DAC module.
[in]u32ChNot used in M480 DAC.
Return values
0DAC is in conversion state.
1DAC conversion finish.

This macro is used to read FINISH bit (DAC_STATUS[0]) to get DAC conversion complete finish flag.

Definition at line 205 of file dac.h.

◆ DAC_IS_BUSY

#define DAC_IS_BUSY (   dac,
  u32Ch 
)

Get the busy state of DAC.

Parameters
[in]dacBase address of DAC module.
[in]u32ChNot used in M480 DAC.
Return values
0Idle state.
1Busy state.

This macro is used to read BUSY bit (DAC_STATUS[8]) to get busy state.

Definition at line 194 of file dac.h.

◆ DAC_READ_DATA

#define DAC_READ_DATA (   dac,
  u32Ch 
)

Read DAC 12-bit holding data.

Parameters
[in]dacBase address of DAC module.
[in]u32ChNot used in M480 DAC.
Returns
Return DAC 12-bit holding data.

This macro is used to read DAC_DAT register.

Definition at line 183 of file dac.h.

◆ DAC_START_CONV

#define DAC_START_CONV (   dac)

Start the D/A conversion.

Parameters
[in]dacBase address of DAC module.
Returns
None

User writes SWTRG bit (DAC_SWTRG[0]) to generate one shot pulse and it is cleared to 0 by hardware automatically.

Definition at line 68 of file dac.h.

◆ DAC_WRITE_DATA

#define DAC_WRITE_DATA (   dac,
  u32Ch,
  u32Data 
)

Write data for conversion.

Parameters
[in]dacBase address of DAC module.
[in]u32ChNot used in M480 DAC.
[in]u32DataDecides the data for conversion, valid range are between 0~0xFFF.
Returns
None

12 bit left alignment: user has to load data into DAC_DAT[15:4] bits. 12 bit right alignment: user has to load data into DAC_DAT[11:0] bits.

Definition at line 173 of file dac.h.

Function Documentation

◆ DAC_Close()

void DAC_Close ( DAC_T dac,
uint32_t  u32Ch 
)

Disable DAC analog power.

Parameters
[in]dacBase address of DAC module.
[in]u32ChNot used in M480 DAC.
Returns
None

Disable DAC analog power for saving power consumption.

Definition at line 61 of file dac.c.

◆ DAC_Open()

void DAC_Open ( DAC_T dac,
uint32_t  u32Ch,
uint32_t  u32TrgSrc 
)

This function make DAC module be ready to convert.

Parameters
[in]dacBase address of DAC module.
[in]u32ChNot used in M480 DAC.
[in]u32TrgSrcDecides the trigger source. Valid values are:
Returns
None

The DAC conversion can be started by writing DAC_DAT, software trigger or hardware trigger. When TRGEN (DAC_CTL[4]) is 0, the data conversion is started by writing DAC_DAT register. When TRGEN (DAC_CTL[4]) is 1, the data conversion is started by SWTRG (DAC_SWTRG[0]) is set to 1, external STDAC pin, timer event, or EPWM event.

Definition at line 46 of file dac.c.

◆ DAC_SetDelayTime()

uint32_t DAC_SetDelayTime ( DAC_T dac,
uint32_t  u32Delay 
)

Set delay time for DAC to become stable.

Parameters
[in]dacBase address of DAC module.
[in]u32DelayDecides the DAC conversion settling time, the range is from 0~(1023/PCLK1*1000000) micro seconds.
Returns
Real DAC conversion settling time (micro second).

For example, DAC controller clock speed is 160MHz and DAC conversion setting time is 1 us, SETTLET (DAC_TCTL[9:0]) value must be greater than 0xA0.

Note
User needs to write appropriate value to meet DAC conversion settling time base on PCLK (APB clock) speed.

Definition at line 74 of file dac.c.