cancel
Showing results for 
Search instead for 
Did you mean: 

No DAC output

jtozz.1
Associate II

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 */

 }

}

1 ACCEPTED SOLUTION

Accepted Solutions
Piranha
Chief II

> 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.

View solution in original post

10 REPLIES 10

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

Activate the dac buffer

jtozz.1
Associate II

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 Employee

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 Accept as Solution on the reply which solved your issue or answered your question.

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
Associate II

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
Chief II

> 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
Associate II

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.

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