STM32G473 DAC3 to OPAMP output stuck at low.
I'm trying to generate a signal from DAC3 (connected only to internal peripherals) from my G473 and output that value through OPAMP1 in follower mode. The output of the pin of the OPAMP is stuck at low forever however. I set the DAC from CUBEIDE as such:
static void MX_DAC3_Init(void)
{
DAC_ChannelConfTypeDef sConfig = {0};
hdac3.Instance = DAC3;
if (HAL_DAC_Init(&hdac3) != HAL_OK) {
Error_Handler();
}
/** DAC channel OUT1 config
*/
sConfig.DAC_HighFrequency = DAC_HIGH_FREQUENCY_INTERFACE_MODE_AUTOMATIC;
sConfig.DAC_DMADoubleDataMode = DISABLE;
sConfig.DAC_SignedFormat = DISABLE;
sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE;
sConfig.DAC_Trigger = DAC_TRIGGER_NONE;
sConfig.DAC_Trigger2 = DAC_TRIGGER_NONE;
sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_DISABLE;
sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_INTERNAL;
sConfig.DAC_UserTrimming = DAC_TRIMMING_FACTORY;
if (HAL_DAC_ConfigChannel(&hdac3, &sConfig, DAC_CHANNEL_1) != HAL_OK){
Error_Handler();
}
}I set the OPAMP from CUBEIDE as such:
static void MX_OPAMP1_Init(void){
hopamp1.Instance = OPAMP1;
hopamp1.Init.PowerMode = OPAMP_POWERMODE_NORMAL;
hopamp1.Init.Mode = OPAMP_FOLLOWER_MODE;
hopamp1.Init.NonInvertingInput = OPAMP_NONINVERTINGINPUT_DAC;
hopamp1.Init.InternalOutput = DISABLE;
hopamp1.Init.TimerControlledMuxmode = OPAMP_TIMERCONTROLLEDMUXMODE_DISABLE;
hopamp1.Init.UserTrimming = OPAMP_TRIMMING_FACTORY;
if (HAL_OPAMP_Init(&hopamp1) != HAL_OK)
{
Error_Handler();
}
}And then on my main function, I enable DAC:
HAL_DAC_Start(&hdac3, DAC_CHANNEL_1);and on the while loop, I set the value of the DAC:
while (1)
{
/* USER CODE BEGIN 3 */
var = value * (0xfff+1)/3.3;
HAL_DAC_SetValue(&hdac3, DAC_CHANNEL_1, DAC_ALIGN_12B_R, var);
value += 0.5;
HAL_Delay(100);
if (value > 3) value = 0.2;
}Am I configuring something wrong. Is there an additional function I need to call to setup the OPAMP? DAC1 and DAC2 are in perfect working condition. Thank you!
