cancel
Showing results for 
Search instead for 
Did you mean: 

internal DAC (DAC3) connection to OPAMP1 - no output from OPAMP

YLivn.1
Associate II

Hey,

I'm using: STM32G431, NUCLEO-G431RB

I would like to connect DAC3 - internally to the OPAMP and take the OPAMP1 output. I have an array I want to transfer to the dac3 via DMA, the timing is controlled by tim2.

Then having DAC3 to be the non-inverting input for the OpAmp.

When trying to take the output externally from the Opamp output - no signal.

By the way, the code works fine for DAC1 and DMA, but I want to use DAC3 for the fast sampling rate.

Can you help?

Thanks!

int main(void)
{
...
HAL_DAC_Start_DMA(&hdac3, DAC_CHANNEL_1, (uint32_t*)arr_to_play, NS, DAC_ALIGN_12B_R);
HAL_OPAMP_Start(&hopamp1);
HAL_TIM_Base_Start(&htim2);
....
}
 
static void MX_OPAMP1_Init(void)
{
  hopamp1.Instance = OPAMP1;
  hopamp1.Init.PowerMode = OPAMP_POWERMODE_HIGHSPEED;
  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();
  }

1 ACCEPTED SOLUTION

Accepted Solutions

> I can't output the DAC[3] to a pin

I don't actively use the 'G4 so didn't realize that, sorry.

I may have overlooked something else, too. Isn't there an example in Cubeg4, involving DAC3?

I presume you've double-checked that OPAMP1 is working, maybe even trying to switch it input into some of the pins instead of DAC3.

There are not many options there, IMO, you can check DAC 3 on OPAMP6, or on COMP1/COMP3, so you may want to try some of those. You may also perhaps try for the experiments to control DAC3 entirely manually, i.e avoiding DMA and TIM2.

JW

View solution in original post

6 REPLIES 6

Which STM32?

Read out and check/post the relevant DAC and OPAMP register content.

JW

YLivn.1
Associate II

Hey @Community member​ 

STM32G431, NUCLEO-G431RB

attaching an excel of the relevant register content.

Can't see anything suspicious, maybe except DAC_MCR.SINFORMAT=1, is it intentional?

In any case, you can try to output the DAC onto a pin directly and measure difference of that, and the OPAMP output.

JW

YLivn.1
Associate II

Yeah the sign enable is intentional.

I can't output the DAC to a pin as it is not an external DAC. Notice I'm using DAC3 and it is an internal DAC (again, intentional)

> I can't output the DAC[3] to a pin

I don't actively use the 'G4 so didn't realize that, sorry.

I may have overlooked something else, too. Isn't there an example in Cubeg4, involving DAC3?

I presume you've double-checked that OPAMP1 is working, maybe even trying to switch it input into some of the pins instead of DAC3.

There are not many options there, IMO, you can check DAC 3 on OPAMP6, or on COMP1/COMP3, so you may want to try some of those. You may also perhaps try for the experiments to control DAC3 entirely manually, i.e avoiding DMA and TIM2.

JW

thanks!

I did what you suggested, and switched the DAC channel & Opamp. It helped, and works! thanks :)