cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G474MCT3TR DAC no output

Tony512
Associate

Hi guys:

          My project DAC setting as below:

          Pin_setting.pngpin2.png

 

           And my project that initial and code as below, it's works on EVM board (STM32G474RETX), but now works on STM32G474MCT3TR, does anyone encounter this situation?

          

static void MX_DAC1_Init(void)
{

/* USER CODE BEGIN DAC1_Init 0 */

/* USER CODE END DAC1_Init 0 */

DAC_ChannelConfTypeDef sConfig = {0};

/* USER CODE BEGIN DAC1_Init 1 */

/* USER CODE END DAC1_Init 1 */

/** DAC Initialization
*/
hdac1.Instance = DAC1;
if (HAL_DAC_Init(&hdac1) != HAL_OK)
{
Error_Handler();
}

/** DAC channel OUT1 config
*/
sConfig.DAC_HighFrequency = DAC_HIGH_FREQUENCY_INTERFACE_MODE_AUTOMATIC;
sConfig.DAC_DMADoubleDataMode = DISABLE;
sConfig.DAC_SignedFormat = DISABLE;
sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE;
sConfig.DAC_Trigger = DAC_TRIGGER_NONE;
sConfig.DAC_Trigger2 = DAC_TRIGGER_NONE;
sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_EXTERNAL;
sConfig.DAC_UserTrimming = DAC_TRIMMING_FACTORY;
if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_1) != HAL_OK)
{
Error_Handler();
}

/** DAC channel OUT2 config
*/
if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN DAC1_Init 2 */

/* USER CODE END DAC1_Init 2 */

}

 

void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};
  if(hdac->Instance==DAC1)
  {
  /* USER CODE BEGIN DAC1_MspInit 0 */

  /* USER CODE END DAC1_MspInit 0 */
    /* Peripheral clock enable */
    __HAL_RCC_DAC1_CLK_ENABLE();

    __HAL_RCC_GPIOA_CLK_ENABLE();
    /**DAC1 GPIO Configuration
    PA4     ------> DAC1_OUT1
    PA5     ------> DAC1_OUT2
    */
    GPIO_InitStruct.Pin = MCU_BUS_I_SHARE_OUT_Pin|MCU_DEBUG_DAC_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

  /* USER CODE BEGIN DAC1_MspInit 1 */

  /* USER CODE END DAC1_MspInit 1 */

  }

}

uint16_t dac_value=2048;

HAL_DAC_Start(&hdac1, DAC_CHANNEL_1);
HAL_DAC_SetValue(&hdac1, DAC_CHANNEL_1, DAC_ALIGN_12B_R, dac_value);

HAL_DAC_Start(&hdac1, DAC_CHANNEL_2);
HAL_DAC_SetValue(&hdac1, DAC_CHANNEL_2, DAC_ALIGN_12B_R, dac_value);

 

 

Thanks a lot

Tony

1 ACCEPTED SOLUTION

Accepted Solutions

Hi JW:

           I change the another PCB Board and it's can DAC output normally.

           I think that is hardware issue.

           Thanks for your help!

 

Tony

View solution in original post

4 REPLIES 4

> it's works on EVM board (STM32G474RETX), but now works on STM32G474MCT3TR

So, where's the problem, and what are its exact symptoms?

How is reference (VREF+ pin) set up and what voltage do you measure there?

How are the DAC pins connected? Do you take into consideration their limited output current?

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

JW

 

Hi waclawek.jan:

      The symptoms is that I can't control the DAC output 1.65v for the STM32G474MCT3TR MCU, I measure the VREF = 3.3v, VDDA also 3.3v, but still no DAC output 1.65v. I measure the DAC output by contact the STM32G474MCT3TR MCU' pin PA4 & PA5. Finally I check the DAC registers also correct too.

 

     Is another possible problem of the STM32G474MCT3TR MCU setting or limitation? Clock? (Now system clock is 170MHz for DAC)

 

 

Thanks a lot

Tony

 

> Finally I check the DAC registers also correct too

Show. And show also relevant GPIO registers content.

JW

Hi JW:

           I change the another PCB Board and it's can DAC output normally.

           I think that is hardware issue.

           Thanks for your help!

 

Tony