cancel
Showing results for 
Search instead for 
Did you mean: 

Using DFSDM peripheral to read from sigma delta modulators (AD7403 specifically).

dan0
Associate II

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

2 REPLIES 2

> the conversion values I'm seeing don't make sense

Why do you think so?

Read out the DFSDM registers content and check. Observe the signals by oscilloscope/LA and compare against Channel transceiver timing diagrams figure in RM and timing parameters given in DS.

JW

dan0
Associate II

The output of the AD7403 is a bitstream, thus moving so hard to capture and compare with a datasheet diagram.

My first question is, the AD7403 is a 16bit ADC, does that mean i need to use the right bit shift in ST DFSDM peripheral?

Secondly, AD7403 datasheet says the output must be decimated by 256 (or more). Does the peripheral have the ability to do this?