2023-11-16 04:40 AM
Hi all,
I am in the process of bringing up a prototype board with a STM32L4R7ZIT6 up. I'm using one DAC channel via the opamp. This is working all right, until I designate the default output of the DAC to another function e.g. dig output.
The DAC is configured as 'only to on chip peripherals.' If the io-pin is at reset state, the output voltage appears at the opamp output pin.
I am using CubeMX for generating the startup code. 75% of the IO is configured. I hope someone has a clue.
2023-11-16 10:43 AM
Default state of GPIO is "analog" for all stm32 I've seen, if you configure GPIO as digital output alter on analog mode will be disconnected.
2023-11-17 12:53 AM
Hi MasterT
According to the manual and CubeMX, the DAC can be connected to 'internal peripherals only '
In that situation the outputbuffer is disabled by CubeMX. So the physical IO is disconnected. And therefor should not have any influence on the DAC IMHO.
2023-11-17 06:12 AM
Plz, be more specific. What DAC number, OPA number, GPIO port (A, B, C....) pins used.
My comments is on assumption that OPA is activated, and "reset state = analog mode" means OPA output connected to associated GPIO in default state. If it's not acceptable you have options to regonfigure GPIO to any mode except analog or switch off OPA.
2023-11-17 07:14 AM
Hi MasterT,
The DAC # is 1, the only DAC in this MPU, Channel is 1, OPA# is 1, GPIO is PA4, exclusively designated to DAC1 channel 1. OPA output is on PA3
In my IO-setting, I need PA4 for its function as 'spi1_nss'. For my application, I like to lower the output impedance of the DAC. So, two flies in one catch. Use the OPA as a follower, and free PA4. The strange thing is, this is working OK when PA4 is in reset state. So the DAC is feeding the OPA, and the OPA is conveying the votage 1:1 to output PA3. When I set PA4 to 'reset state' the setup is working as expected. When I set PA4 to an output, or SP1_NSS, the voltage on PA3 does not follow the value set to the DAC. Checking the settings of the DAC and the OPA in the debugger shows exactly the same values in both situations.
When I have PA4 in reset state, and it is working as desired, I can change the state of PA4 in the debugger by modifing the two MODER4 bits. In reset state it is 3. With every other value, the output value of the PA (PA3) is immediately lowered to 0,3 V. When changed back to 3. the desired value apears again.
Pic 1: Desired situation, not working
Pic2: Situation that is working:
2023-11-17 11:02 AM
I see. I'd suggest to check out bits fild in the DAC register, if it's realy connected to on-chip analog only. CubeMX may have bugs.
22.7.16 DAC mode control register (DAC_MCR)
Bits 2:0 MODE1[2:0]: DAC channel1 mode
These bits can be written only when the DAC is disabled and not in the calibration mode
(when bit EN1 = 0 and bit CEN1 = 0 in the DAC_CR register). If EN1 = 1 or CEN1 = 1 the
write operation is ignored.
They can be set and cleared by software to select the DAC channel1 mode:
– DAC channel1 in Normal mode
000: DAC channel1 is connected to external pin with Buffer enabled
001: DAC channel1 is connected to external pin and to on chip peripherals with Buffer
enabled
010: DAC channel1 is connected to external pin with Buffer disabled
011: DAC channel1 is connected to on chip peripherals with Buffer disabled
Also read Errata, there is DAC paragraph.
https://www.st.com/en/microcontrollers-microprocessors/stm32l4r7zi.html#
2023-11-22 01:41 AM
Hi MasterT,
I did all that. I also made a new project with only the DAC and OPAMP configurated. It worked as expected correctly. Then I configured PA4 as output. Now there was a fixed value of 0.4V on the output signal on the OPAMP. I compared the initialisation code for the DAC, OPA and the GPIO. Only the GPIO code was different. And correct for the differencies in PA4.
In the debugger I paused the program and changed the MODER4 register of GPIO A to '3' (= reset). The correct analog value imediately appeared on the OPA output. I can only explain this a an impossibility to use PA4 for somethin else when the DAC can1 is used, or as an error in the CPU.
2023-11-30 12:33 AM
Anyone any idea?
2024-04-03 09:03 AM
I just ran into a similar thing. STM32H7, DAC connected internally to OpAmp1 and then OpAmp1 outputting on PC4. I'm trying to use PA4 for Vsync. Vsync is outputting correctly on PA4 until HAL_DAC_Start(&hdac1,DAC_CHANNEL_1); at which point the Vsync pin drops to some low voltage and stays there. Hopefully someone has an answer.....
2024-04-04 01:22 PM
Hi RichH81,
eventually I skipped the DAC and used a timer with PWM and a low pass filter. The filter hardware was already implemented, so I only had to adjust the value of the R and the C.
In no way I could get the DAC running via the opamp and free the PA4 for an other task.
IMHO this is a hardware bug of this chip. (And apparently also for other chips) I’d expect ST to be happy someone found it, but I’m afraid they missed it. (Maybe I am to arrogant now)
Hopefully this is a solution for you.