2020-10-28 03:34 AM
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();
}
Solved! Go to Solution.
2020-10-28 04:46 PM
> 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
2020-10-28 05:53 AM
Which STM32?
Read out and check/post the relevant DAC and OPAMP register content.
JW
2020-10-28 06:22 AM
2020-10-28 08:24 AM
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
2020-10-28 08:27 AM
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)
2020-10-28 04:46 PM
> 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
2020-11-03 06:21 AM
thanks!
I did what you suggested, and switched the DAC channel & Opamp. It helped, and works! thanks :)