DAC Library
DAC (Digital to Analog Converter) module is available with a number of ARM MCU modules. DAC is an electronic circuit that converts discrete digital numbers to continuous signals. DAC Library provides you a comfortable work with the module.
Library Routines
- DACx_Init
- DACx_Init_Advanced
- DACx_Advanced_Chy_Output
- DACx_Chy_Output
- DAC1_Dual_Output
- DACx_Output
- DACx_Deinit
DACx_Init
| Prototype |
void DACx_Init(unsigned int channel); // for Kinetis devicesvoid DACx_Init(); |
||||||||
|---|---|---|---|---|---|---|---|---|---|
| Description |
This routine initializes DAC module and sets used channel. |
||||||||
| Parameters |
|
||||||||
| Returns |
Nothing. |
||||||||
| Requires |
|
||||||||
| Example |
DAC1_Init(_DAC_CH1_ENABLE); // Initialize DAC1 module for STM32 device, channel 1 DAC1_Init(); // Initialize DAC1 module for Kinetis device |
||||||||
| Notes |
|
DACx_Init_Advanced
| Prototype |
void DACx_Init_Advanced(unsigned long config); |
||||||||
|---|---|---|---|---|---|---|---|---|---|
| Description |
This routine initializes DAC module according to custom configuration. |
||||||||
| Parameters |
|
||||||||
| Returns |
Nothing. |
||||||||
| Requires |
|
||||||||
| Example |
DAC0_Init_Advanced(_DAC_CFG_REFVOLT_SRC_VREF1 || _DAC_CFG_LOWPOWER_ENABLED); |
||||||||
| Notes |
|
DACx_Advanced_Chy_Output
| Prototype |
void DACx_Advanced_Chy_Output(unsigned long value, unsigned long config); |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Description |
This routine outputs analog value from the DAC module with user defined settings. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Parameters |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Returns |
Nothing. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Requires |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Example |
DAC1_Advanced_Ch1_Output(2047, _DAC_12_BIT | DAC_RIGHT_ALIGN | _DAC_WAVE_DISABLED | _DAC_TRIGGER_SW); // get output from the channel 1 of DAC1 module |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Notes |
|
DACx_Chy_Output
| Prototype |
void DACx_Chy_Output(unsigned long value); |
|---|---|
| Description |
This routine outputs value from the DAC module and channel with the default settings :
|
| Parameters |
value: output voltage value. This value is in range of 0-4095. The output analog voltage is calculated according to the equation: DACoutput = VREF * value/4095,
where VREF is the voltage reference value from the VREF pin.
|
| Returns |
Nothing. |
| Requires |
|
| Example |
DAC1_Ch2_Output(127); // get output from the channel 2 of DAC1 module |
| Notes |
|
DAC1_Dual_Output
| Prototype |
void DAC1_Dual_Output(unsigned long value1, unsigned long value2, unsigned long config1, unsigned long config2); |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Description |
This routine outputs value from both channels of the DAC1 module with user defined settings. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Parameters |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Returns |
Nothing. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Requires |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Example |
DAC1_Dual_Output(2047, _DAC_12_BIT, 511, _DAC_8_BIT); // get output from both channels of DAC1 module |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Notes |
|
DACx_Output
| Prototype |
void DACx_Output(unsigned int value); |
|---|---|
| Description |
This routine drives the DAC module to output DAC value. |
| Parameters |
|
| Returns |
Nothing. |
| Requires |
|
| Example |
DAC1_Output(2047); // get output from DAC1 module |
| Notes |
|
DACx_Deinit
| Prototype |
void DACx_Deinit(); |
|---|---|
| Description |
This function deinitializes previously used DAC module |
| Parameters |
None. |
| Returns |
Nothing. |
| Requires |
|
| Example |
DAC1_Deinit(); // deinitialize DAC1 module |
| Notes |
|
What do you think about this topic ? Send us feedback!



