3.3 Performing a DA Conversion

Description

When you perform a D/A conversion, you are essentially taking a digital value and converting it to a voltage value that you send out to the specified analog output. This output code can be translated to an output voltage using one of the equations described in the hardware manual.‌

The SAMD51 function for performing a D/A conversion is DSCSAM_DAConvert.‌

Step-By-Step Instructions

Call DSCSAM_DAConvert and pass it BYTE and unsigned int values for the channel, LoadCal and output code - this will generate a D/A conversion on the selected channel that will output the new voltage that you set with the output code.‌

NOTE: Once you generate a D/A conversion on a specific output channel, that channel will continue to maintain the specified voltage until another conversion is done on the same channel or the board is reset or shut down. For a DAC, the range of output code is from 0 to 4095.‌

Example of Usage for D/A Conversion

...

BYTE channel=0,Loadcal=0;
unsigned int DACode=0;
ERRPARAMS errparams;  // structure for returning error code and error string

...	

/* Step 1 */ 

channel = 0;
DACode = 4095;
Loadcal = 1;

if(DSCSAM_DAConvert(channel,DACode,Loadcal) != DE_NONE)
{
    DSCGetLastError ( &errparams );
    printf ( "DSCSAM_DAConvert error: %s %s\n", DSCGetErrorString ( errparams.ErrCode ), errparams.errstring );
    return 0;
}

...

Last updated