Skip to main content
jtozz.1
Associate
October 31, 2022
Solved

No DAC output

  • October 31, 2022
  • 10 replies
  • 3340 views

It seems so easy, but I get no signal to the pin PA4. I use STM32f103VCT, any Idea ?

int main(void)

{

 /* USER CODE BEGIN 1 */

 /* USER CODE END 1 */

 /* MCU Configuration--------------------------------------------------------*/

 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

 HAL_Init();

 /* USER CODE BEGIN Init */

 /* USER CODE END Init */

 /* Configure the system clock */

 SystemClock_Config();

 /* USER CODE BEGIN SysInit */

 /* USER CODE END SysInit */

 /* Initialize all configured peripherals */

 MX_GPIO_Init();

 MX_DAC_Init();

 /* USER CODE BEGIN 2 */

    HAL_DAC_Start(&hdac, DAC_CHANNEL_1);

    HAL_DAC_SetValue(&hdac, DAC_CHANNEL_1,DAC_ALIGN_12B_R, 3000);

 /* USER CODE END 2 */

 /* Infinite loop */

 /* USER CODE BEGIN WHILE */

 while (1)

 {

   /* USER CODE END WHILE */

   /* USER CODE BEGIN 3 */

 /* USER CODE END 3 */

 }

}

This topic has been closed for replies.
Best answer by Piranha

> but when I reconfigured the registers to input pin I found the same 0V

Those pins must be in analog mode.

And VDDA/VSSA and VREF+/VREF- must be supplied with the proper voltages.

10 replies

waclawek.jan
Super User
October 31, 2022

Read out and check/post content of DAC and relevant GPIO registers.

Note, that DAC output is of relatively high impedance so PA4 is heavily loaded externally, it won't be able to drive that pin adequately.

JW

S.Ma
Principal
November 1, 2022

Activate the dac buffer

jtozz.1
jtozz.1Author
Associate
November 1, 2022

Thx for your answers, The output buffer is enable and the load connected to the pin is 10K.

The VDDA pin is to 3.3V. You can see that 3000 ==> 0xbb8 is in the dac register. But 0V on pin pa4. Why ???

0693W00000VOaXIQA1.png0693W00000VOaXDQA1.png

Amel NASRI
ST Technical Moderator
November 8, 2022

Hi @jtozz.1​ ,

Based on the example DAC_SimpleConversion, main DAC related functions are used in this order:

  1. HAL_DAC_Init
  2. HAL_DAC_ConfigChannel
  3. HAL_DAC_SetValue
  4. HAL_DAC_Start

Try to follow this order in your code or reproduce the same example as in STM32Cube_F1 first.

-Amel

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.
waclawek.jan
Super User
November 8, 2022

Registers look OK.

Have you measured directly on the PIN? Try setting PA4 as GPIO Out and toggle in program while measuring.

Is this a genuine ST part? Isn't it a counterfeit one? You can check on some of the "known good" boards like Nucleo or Disco.

JW

jtozz.1
jtozz.1Author
Associate
November 15, 2022

MX_DAC_Init(); does HAL_DAC_Init and HAL_DAC_ConfigChannel, I shift HAL_DAC_SetValue and HAL_DAC_Start to have the same order as you wrote. But the same result, 0V to the pin.

I tried to toggle the GPIO register on debugging, It works, as output I had 3.3V or 0V depending ODR register, but when I reconfigured the registers to input pin I found the same 0V.

The same kind of code works easily with the nucleo stm32g491.

Here is the MCU I use, soldered by jlc pcb. May be you wright, this chip and the others I received are fake. Any one can confirm me that is (or not) a ST part ?

0693W00000WIOboQAH.jpg

Piranha
PiranhaBest answer
Principal III
November 19, 2022

> but when I reconfigured the registers to input pin I found the same 0V

Those pins must be in analog mode.

And VDDA/VSSA and VREF+/VREF- must be supplied with the proper voltages.

jtozz.1
jtozz.1Author
Associate
November 20, 2022

Thx Piranha, I missundertsood the Vref connection. Vref+/Vref- are not connected to VDDA and VSSA on my package. I added solder to make the connection and it works fine.

Thank you very much.

Piranha
Principal III
November 20, 2022

Just in case... Read the AN2586. :)

waclawek.jan
Super User
November 22, 2022

Nice catch, Piranha!

@jtozz.1​ , please select Piranha's answer as Best so that thread is marked as solved.

JW