I'm trying to initialize the DAC on the LPC4337, I've read the DAC section of the manual and used the debugger to gain access of the DAC registers. I was able to "Enable" or set bit 3 of the CTRL register, set the CNTVAL register at 0x0000 and I put my 10 bit value in the CR register (15:6 bit) and my board does output the right analog voltage. However when I try to implement this in the code, it's not working. I don't see the CTRL bit 3 changing so I believe my initialization of the DAC isn't correct. I cannot find any documentation on this and all the examples I see either are gibberish or older/other IDEs. I'm using both LPCxpresso and MCUxpresso.
/* p4_4 ADC0_0, GPIO 2_4*/
Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, 2, 4); // set GPIO port direction register
Chip_SCU_PinMuxSet(0x4,4,SCU_MODE_INACT); // disable pull up and pull down resistor
LPC_SCU->SFSP[0x4] &= ~(1<<6);//disable receiveing by setting the EZI bit to zero.
Chip_SCU_DAC_Analog_Config(); //select DAC function
Chip_DAC_Init(LPC_DAC); //initialize DAC
I have also tried to do LPC_DAC -> to write the registers but that didn't work either. Any and all help will be appreciated.