1

I have an AMC1306 current shunt modulator feeding 1-bit PDM data at 10 MHz into a STM32L475. Filter0 takes the bit stream from Channel0 and applies a sinc3 filter with Fosr=125 and Iosr=4. This provides 24-bit data at 20 kHz and is working fine. The DMA transfers the data into a 1-word circular buffer in main memory to maintain fresh data.

I want to be able to call an interrupt function if the 24-bit value leaves a certain window. This would be caused in an over-voltage situation and needs to disengage the MOSFET driver. It would seem this functionality is offered by the analogue watchdog within the peripheral.

I am using STM32CubeIDE and the graphical interface within the IDE to configure the peripherals. Filter0 global interrupts are enabled. I have added this code:

/* USER CODE BEGIN 2 */
  HAL_DFSDM_FilterRegularStart_DMA(&hdfsdm1_filter0, Vbus_DMA, 1);

  // Set up the watchdog
  DFSDM_Filter_AwdParamTypeDef awdParamFilter0;
  awdParamFilter0.DataSource = DFSDM_FILTER_AWD_FILTER_DATA;
  awdParamFilter0.Channel = DFSDM_CHANNEL_0;
  awdParamFilter0.HighBreakSignal = DFSDM_NO_BREAK_SIGNAL;
  awdParamFilter0.HighThreshold = 250;
  awdParamFilter0.LowBreakSignal = DFSDM_NO_BREAK_SIGNAL;
  awdParamFilter0.LowThreshold = -250;

  HAL_DFSDM_FilterAwdStart_IT(&hdfsdm1_filter0, &awdParamFilter0);
/* USER CODE END 2 */

I have also used the HAL callback function

/* USER CODE BEGIN 4 */
void HAL_DFSDM_FilterAwdCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t Channel, uint32_t Threshold)
{
    HAL_GPIO_WritePin(GPIOA, LED_Pin, GPIO_PIN_SET);
}
/* USER CODE END 4 */

But the callback function never runs! I have experimented with the thresholds (I even made them zero).

Debugger output

In the debugger I can see the AWDIE=0x1 (So the AWD interrupt is enabled). The AWDF = 0x1 (So the threshold has been crossed and the peripheral should be requesting an interrupt...). The code doesn't even trigger a breakpoint in the stm32l4xx_it.c filter0 interrupt. So it'd seem no DFSDM1_FLT0 interrupts are happening

I'd be enormously appreciative of any help, any example code, any resources to read. Thanks in advance.

I know the DMA conversion complete callbacks work I have played around with various thresholds and note that the AWDF gets set when the threshold is crossed.

1 Answers1

1

I have finally found the solution to this.

I added:

HAL_NVIC_EnableIRQ(DFSDM1_FLT1_IRQn);

You'd have thought HAL_DFSDM_FilterAwdStart_IT() would do this for you like all other HALL_xx_IT() routines!

I have switched to using the channel data rather than the filter data to trigger the AWD. If doing this you need to left shift your threshold values by 8.

// Enable the interrupts by the analogue watchdog
DFSDM_Filter_AwdParamTypeDef awdParamFilter1;
awdParamFilter1.DataSource = DFSDM_FILTER_AWD_CHANNEL_DATA;
awdParamFilter1.Channel = DFSDM_CHANNEL_1;
awdParamFilter1.HighBreakSignal = DFSDM_NO_BREAK_SIGNAL;
awdParamFilter1.HighThreshold = 1024 << 8;
awdParamFilter1.LowBreakSignal = DFSDM_NO_BREAK_SIGNAL;
awdParamFilter1.LowThreshold = -1024 << 8;
HAL_DFSDM_FilterAwdStart_IT(&hdfsdm1_filter1, &awdParamFilter1);
user16217248
  • 3,119
  • 19
  • 19
  • 37
  • James, if you check in the .ioc graphical editor of CubeIDE (the integrated CubeMx part of the IDE), under DFSDM, is there a tab next to parameters, DMA etc to configure NVIC? If so, tick that such that you do not have to enable IRQ in your user code. – JeromeBu1982 Apr 23 '23 at 12:05