cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H753XI-EVAL DAC Channel 2 on PA5 not working

HugoSTM32
Visitor

Post edited by ST moderator to be inline with the community rules for the code sharing. In next time please use </> button to paste your code. Please read this post: How to insert source code.

Hi,

I am new to STM32 and I have to do a data acquisition board project using the STM32H7 MCU.

I have the STM32H753XI-EVAL evaluation kit and I am trying out all the features one by one.

I'm currently working on the DAC, which I have configured on CHANNEL2 on PA5. I am trying to start it up, send it a value, and then get its value to check and measure it using a voltmeter on PA5 of CN6 on the evaluation board.


DAC1_Init : 

 
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 OUT2 config

*/

sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE;

sConfig.DAC_Trigger = DAC_TRIGGER_NONE;

sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;

sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_DISABLE;

sConfig.DAC_UserTrimming = DAC_TRIMMING_FACTORY;

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



}


DAC MSP

 
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_DAC12_CLK_ENABLE();



__HAL_RCC_GPIOA_CLK_ENABLE();

/**DAC1 GPIO Configuration

PA5 ------> DAC1_OUT2

*/

GPIO_InitStruct.Pin = GPIO_PIN_5;

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



}



}

main

 
HAL_DAC_Start(&hdac1, DAC_CHANNEL_2);

uint32_t value = 3000;

HAL_DAC_SetValue(&hdac1, DAC_CHANNEL_2, DAC_ALIGN_12B_R, value);

uint32_t dac_val = HAL_DAC_GetValue(&hdac1, DAC_CHANNEL_2);



char buf[50];

int len = snprintf(buf, sizeof(buf), "DAC Set Value: %lu | DAC Get Value: %lu\r\n", value, dac_val);

HAL_UART_Transmit(&huart1, (uint8_t*)buf, len, HAL_MAX_DELAY);

Results :

UART : DAC Set Value: 3000 | DAC Get Value: 3000
Volt : 2.3V No matter what value I set.

Have a great day

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Super User

According to the schematic, pin PA5 is in use on that board for the ULCP_CK function. It is being driving by U13. You can disconnect it from this by removing R118.

STM32H753I-EVAL | Product - STMicroelectronics

TDK_0-1762264267878.png

 

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

2 REPLIES 2
TDK
Super User

According to the schematic, pin PA5 is in use on that board for the ULCP_CK function. It is being driving by U13. You can disconnect it from this by removing R118.

STM32H753I-EVAL | Product - STMicroelectronics

TDK_0-1762264267878.png

 

If you feel a post has answered your question, please click "Accept as Solution".
HugoSTM32
Visitor

Ok that worked, i removed the R118 and it worked well.

Thank you very much !!!