Question
Using DFSDM peripheral to read from sigma delta modulators (AD7403 specifically).
Trying use the dsfdm peripheral on the STM32L452 MCU to read from an AD7403 adc. The ADC is clocking out data, but the conversion values I'm seeing don't make sense.
DFSDM setup is below. GPIO and setup in other functions. Those setups are OK because i see the conversion value changing, but not linearly with increases in ADC input voltage.
static void DFSDM_Init(void)
{
/* Initialize channel - (voltage channel)*/
__HAL_DFSDM_CHANNEL_RESET_HANDLE_STATE(&DfsdmVoltageChannelHandle);
DfsdmVoltageChannelHandle.Instance = DFSDM1_Channel0; //Channel 0 should be NTC L - PA7
DfsdmVoltageChannelHandle.Init.OutputClock.Activation = ENABLE;
DfsdmVoltageChannelHandle.Init.OutputClock.Selection = DFSDM_CHANNEL_OUTPUT_CLOCK_SYSTEM;
DfsdmVoltageChannelHandle.Init.OutputClock.Divider = 15; /* 80 MHz/16 = 5MHz */
DfsdmVoltageChannelHandle.Init.Input.Multiplexer = DFSDM_CHANNEL_EXTERNAL_INPUTS;
DfsdmVoltageChannelHandle.Init.Input.DataPacking = DFSDM_CHANNEL_STANDARD_MODE; /* N.U. */
DfsdmVoltageChannelHandle.Init.Input.Pins = DFSDM_CHANNEL_SAME_CHANNEL_PINS;
DfsdmVoltageChannelHandle.Init.SerialInterface.Type = DFSDM_CHANNEL_SPI_RISING;
DfsdmVoltageChannelHandle.Init.SerialInterface.SpiClock = DFSDM_CHANNEL_SPI_CLOCK_INTERNAL;
DfsdmVoltageChannelHandle.Init.Awd.FilterOrder = DFSDM_CHANNEL_SINC3_ORDER; /* N.U. */
DfsdmVoltageChannelHandle.Init.Awd.Oversampling = 64; /* N.U. */
DfsdmVoltageChannelHandle.Init.Offset = 0;
DfsdmVoltageChannelHandle.Init.RightBitShift = 0;
if(HAL_OK != HAL_DFSDM_ChannelInit(&DfsdmVoltageChannelHandle))
{
Error_Handler();
}
/* Initialize filter 0 */
__HAL_DFSDM_FILTER_RESET_HANDLE_STATE(&DfsdmFilterHandle);
DfsdmFilterHandle.Instance = DFSDM1_Filter0;
DfsdmFilterHandle.Init.RegularParam.Trigger = DFSDM_FILTER_SW_TRIGGER; /* N.U. */
DfsdmFilterHandle.Init.RegularParam.FastMode = DISABLE; /* N.U. */
DfsdmFilterHandle.Init.RegularParam.DmaMode = DISABLE; /* N.U. */
DfsdmFilterHandle.Init.InjectedParam.Trigger = DFSDM_FILTER_EXT_TRIGGER;
DfsdmFilterHandle.Init.InjectedParam.ScanMode = ENABLE;
DfsdmFilterHandle.Init.InjectedParam.DmaMode = DISABLE;
DfsdmFilterHandle.Init.InjectedParam.ExtTrigger = DFSDM_FILTER_EXT_TRIG_TIM1_TRGO;
DfsdmFilterHandle.Init.InjectedParam.ExtTriggerEdge = DFSDM_FILTER_EXT_TRIG_RISING_EDGE;
DfsdmFilterHandle.Init.FilterParam.SincOrder = DFSDM_FILTER_SINC3_ORDER;
DfsdmFilterHandle.Init.FilterParam.Oversampling = 64;
DfsdmFilterHandle.Init.FilterParam.IntOversampling = 64;
if(HAL_OK != HAL_DFSDM_FilterInit(&DfsdmFilterHandle))
{
Error_Handler();
}
/* Configure injected channels for filter 0 (both channels) */
if(HAL_OK != HAL_DFSDM_FilterConfigRegChannel(&DfsdmFilterHandle, DFSDM_CHANNEL_0, DFSDM_CONTINUOUS_CONV_ON))
{
Error_Handler();
}