2022-10-31 10:46 AM
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 */
}
}
Solved! Go to Solution.
2022-11-18 07:51 PM
> 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.
2022-10-31 10:56 AM
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
2022-10-31 06:31 PM
Activate the dac buffer
2022-11-01 02:10 AM
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 ???
2022-11-08 06:26 AM
Hi @jtozz.1 ,
Based on the example DAC_SimpleConversion, main DAC related functions are used in this order:
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.
2022-11-08 09:08 AM
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
2022-11-15 05:20 AM
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 ?
2022-11-18 07:51 PM
> 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.
2022-11-20 08:28 AM
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.
2022-11-20 10:32 AM
Just in case... Read the AN2586. :)