Question
DAC Outputs Not Equal
Hello,
I use the internal DAC of the processor. Even the initial value of the DACs are equal, I got 1V out from the first output of the DAC, and 2V output from the other DAC output. Why is that happen?
/* USER CODE BEGIN PV */
// DAC Settings
float DAC1_Buf = 1.0; // Output 1st of the DAC is designated;
float DAC2_Buf = 1.0; // Output 2nd of the DAC is designated
uint32_t DAC1_Out = 0; // Output 1st of the DAC is designated;
uint32_t DAC2_Out = 0; // Output 2nd of the DAC is designated
/* USER CODE END PV */
/* USER CODE BEGIN 2 */
// HAL_TIM_Base_Start(&htim1); //initializes Timer 1
HAL_DAC_Start(&hdac, DAC_CHANNEL_1);
HAL_DAC_Start(&hdac, DAC_CHANNEL_2);
/* USER CODE END 2 */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
DAC1_Out = (uint32_t)DAC1_Buf*(4096)/3.3;
DAC2_Out = (uint32_t)DAC2_Buf*(4096)/3.3;
HAL_DAC_SetValue(&hdac, DAC_CHANNEL_1, DAC_ALIGN_12B_R, DAC1_Out);
HAL_DAC_SetValue(&hdac, DAC_CHANNEL_2, DAC_ALIGN_12B_R, DAC2_Out);
}
