Using the following configuration code (mostly taken from examples) I am unable to get an output signal on the DAC module.
#include "dac.h"
void InitDAC()
{
configureDAC(DACA);
}
void configureDAC(Uint16 dac_num)
{
EALLOW;
CpuSysRegs.PCLKCR16.bit.DAC_A = 1; // enable DAC_A clock
DacaRegs.DACCTL.bit.DACREFSEL = 1; // use ADC VREFHI instead of an external signal
DacaRegs.DACCTL.bit.LOADMODE = 0; // load on SysClk not PWMSYNC (PWM not yet enabled)
DacaRegs.DACOUTEN.bit.DACOUTEN = 1; // enable output
DacaRegs.DACVALS.all = 0; // output = 0
DELAY_US(10); // Delay for buffered DAC to power up
EDIS;
}
/*
* Sets the DAC's analog voltage based on value
* Equation:
* With DACVALS = DACVALA = value -->
* VDAC = (DACVALA * DACREF) / 4096 -- spruhx5c.pdf page 1364
*
* With VREFHI from ADC the DACREF value should be 3.3V.
* This gives a range for DACVALA of 0 to (4096/3.3) = 1241
*/
void SetDAC(uint16_t DAC, uint16_t value)
{
DacaRegs.DACVALS.all = value;
DELAY_US(2);
}
void TestDAC()
{
uint16_t limit = 1024;
uint16_t v;
// ramp up
for (v = 0; v < limit; v++)
SetDAC(DACA, v);
// ramp down
for (v = limit; v > 0; v--)
SetDAC(DACA, v);
}
I was unable to locate a possible pin mux configuration, so I'm not sure if that's the issue. All configuration registers do get their proper values.
I do use InitSysCtrl() from TI's example code as well, so all peripheral clock should be enabled.
main.c contains:
InitDAC();
for(;;)
{
TestDAC();
DELAY_US(10);
}
I'm reading my voltages with an oscilloscope from pin J4-32 (also probed DAC2-4 on J4-31, J8-72, J8-71 because there is a naming discrepancy between DAC-A and DAC1). Is this the correct pin? What J pin is the ADC VREFHI signal connected to? I have not checked that reference voltage because I haven't found the pinout. Switching between VDAC (with a 3.3V reference signal) and ADC VREFHI does not seem to make a difference either.
I would appreciate any insight, thanks!