cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F303K8 DAC problem

Rad Rad
Associate II
Posted on July 14, 2017 at 13:38

The original post was too long to process during our migration. Please click on the attachment to read the original post.
4 REPLIES 4
Posted on July 17, 2017 at 12:44

And are the GPIO set properly? If you toggle the respective bits in GPIO_ODR, does the output level change?

JW

Zt Liu
Senior III
Posted on July 19, 2017 at 03:47

hi, using my F303K8 nucleo 32 board,

I just test the code of your init and 

HAL_DAC_SetValue() and

 HAL_DAC_Start();

It works fine for both DACx and for three channels.

You may check in your stm32f3xx_hal_msp.c, is there any code looks like:

void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac)

{

   GPIO_InitTypeDef GPIO_InitStruct;

    if(hdac->Instance==DAC1)

   {       

      /* Peripheral clock enable */

      __HAL_RCC_DAC1_CLK_ENABLE();

      /**DAC1 GPIO Configuration

      PA4 ------> DAC1_OUT1

      PA5 ------> DAC1_OUT2

      */

      GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5;

      GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;

      GPIO_InitStruct.Pull = GPIO_NOPULL;

      HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);   

   }

   else if(hdac->Instance==DAC2)

   {

      /* Peripheral clock enable */

      __HAL_RCC_DAC2_CLK_ENABLE();

      /**DAC2 GPIO Configuration

      PA6 ------> DAC2_OUT1

      */

      GPIO_InitStruct.Pin = GPIO_PIN_6;

      GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;

      GPIO_InitStruct.Pull = GPIO_NOPULL;

      HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

   }

}

It seems that, sometime, if you rework on you ioc projects, this msp part is not written or left blank.(not sure about this)

Good luck!

Posted on August 22, 2017 at 11:43

Yes, mine stm32f3xx_hal_msp.c includes these code lines.

Posted on August 22, 2017 at 12:02

yes, output stages are changing respectively, I can drive LED2 & LED3, some other pins also checked and works. DAC control register also seems to be set correctly (to my knowledge), from STM Studio it returns a value of  4128829 = DAC2: 00 00000000111111  DAC1: 00 00000000111101.