由于使用环境的问题H743的DAC输出值有偏差,我想对H743的DAC通道缓冲器进行校准,OTRIM[4:0]位的默认值是16,我尝试更改该位的值(1和31都有尝试),但是DAC的输出电压好像没有什么变化(通过示波器来测量DAC的输出电压)。后面会附上我的代码,有两个问题请教各位大佬:
1.有关缓冲器校准的程序是否有问题?
2.OTRIM[4:0]的范围是0到31,那么步进值是多少呢?我的理解:假如VDD=VDDA=VREFIN=3.3V,OTRIM[4:0]值设置为31,那么步进值 = 3.3/(4096),那么校准后的电压值 = 校准前的电压值 + 31*步进值。不知道我理解的是不是对的。麻烦大佬提供一些帮助。
下面是DAC的配置:
static void DAC_Ch1_Config(void) { DacHandle.Instance = DAC1; /##-1- Initialize the DAC peripheral ######################################/ if (HAL_DAC_Init(&DacHandle) != HAL_OK) { / DAC initialization Error / Error_Handler(); }
/##-2- DAC channel2 Configuration #########################################/ sConfig.DAC_Trigger = DAC_TRIGGER_T6_TRGO; sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE; sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_BOTH; sConfig.DAC_UserTrimming = DAC_TRIMMING_USER; sConfig.DAC_TrimmingValue = 31;
if (HAL_DAC_ConfigChannel(&DacHandle, &sConfig, DAC_CHANNEL_1) != HAL_OK) { / Channel configuration Error / Error_Handler(); }
HAL_DACEx_SelfCalibrate(&DacHandle, &sConfig, DAC_CHANNEL_1);
/##-5- Set DAC channel1 DHR12RD register ################################################/ if (HAL_DAC_SetValue(&DacHandle, DAC_CHANNEL_1, DAC_ALIGN_12B_R, 0x7FF) != HAL_OK) { / Setting value Error / Error_Handler(); }
/##-4- Enable DAC Channel1 ################################################/ if (HAL_DAC_Start(&DacHandle, DAC_CHANNEL_1) != HAL_OK) { / Start Error / Error_Handler(); }
} |