任何想法为什么值在大约高 1 到 2 位中是非线性的?
对于下面的设置,它在 -17000 到 +14000 之间呈线性。将 + 输出加倍只会产生大约 +18000。这些是原始值。在我看来,这真的就像某个地方的溢出。测试输入为直流,在本例中使用 AMC3336
ti 调制器。
我在这里错过了什么?
设置:
- static void MX_DFSDM1_Init(void)
- {
- /* USER CODE BEGIN DFSDM1_Init 0 */
- /* USER CODE END DFSDM1_Init 0 */
- /* USER CODE BEGIN DFSDM1_Init 1 */
- /* USER CODE END DFSDM1_Init 1 */
- hdfsdm1_filter0.Instance = DFSDM1_Filter0;
- hdfsdm1_filter0.Init.RegularParam.Trigger = DFSDM_FILTER_SW_TRIGGER;
- hdfsdm1_filter0.Init.RegularParam.FastMode = DISABLE;
- hdfsdm1_filter0.Init.RegularParam.DmaMode = DISABLE;
- hdfsdm1_filter0.Init.FilterParam.SincOrder = DFSDM_FILTER_SINC3_ORDER;
- hdfsdm1_filter0.Init.FilterParam.Oversampling = 256;
- hdfsdm1_filter0.Init.FilterParam.IntOversampling = 4;
- if (HAL_DFSDM_FilterInit(&hdfsdm1_filter0) != HAL_OK)
- {
- Error_Handler();
- }
- hdfsdm1_channel0.Instance = DFSDM1_Channel0;
- hdfsdm1_channel0.Init.OutputClock.Activation = ENABLE;
- hdfsdm1_channel0.Init.OutputClock.Selection = DFSDM_CHANNEL_OUTPUT_CLOCK_SYSTEM;
- hdfsdm1_channel0.Init.OutputClock.Divider = 12;
- hdfsdm1_channel0.Init.Input.Multiplexer = DFSDM_CHANNEL_EXTERNAL_INPUTS;
- hdfsdm1_channel0.Init.Input.DataPacking = DFSDM_CHANNEL_STANDARD_MODE;
- hdfsdm1_channel0.Init.Input.Pins = DFSDM_CHANNEL_SAME_CHANNEL_PINS;
- hdfsdm1_channel0.Init.SerialInterface.Type = DFSDM_CHANNEL_SPI_RISING;
- hdfsdm1_channel0.Init.SerialInterface.SpiClock = DFSDM_CHANNEL_SPI_CLOCK_INTERNAL;
- hdfsdm1_channel0.Init.Awd.FilterOrder = DFSDM_CHANNEL_SINC3_ORDER;
- hdfsdm1_channel0.Init.Awd.Oversampling = 1;
- hdfsdm1_channel0.Init.Offset = 0;
- hdfsdm1_channel0.Init.RightBitShift = 11;
- if (HAL_DFSDM_ChannelInit(&hdfsdm1_channel0) != HAL_OK)
- {
- Error_Handler();
- }
- if (HAL_DFSDM_FilterConfigRegChannel(&hdfsdm1_filter0, DFSDM_CHANNEL_0, DFSDM_CONTINUOUS_CONV_OFF) != HAL_OK)
- {
- Error_Handler();
- }
- /* USER CODE BEGIN DFSDM1_Init 2 */
- /* USER CODE END DFSDM1_Init 2 */
- }
读:
- int32_t readAMC3336(uint32_t samples) {
- int32_t value;
- uint32_t channel = 0;
- HAL_DFSDM_FilterRegularStart(&hdfsdm1_filter0);
- HAL_StatusTypeDef result = HAL_DFSDM_FilterPollForRegConversion(&hdfsdm1_filter0, 10);
- value = HAL_DFSDM_FilterGetRegularValue(&hdfsdm1_filter0, &channel);
- return value;
- }