Skip to main content
SShir.2
Associate II
September 6, 2021
Question

Is it possible to use analog watchdog without adc interrupt?

  • September 6, 2021
  • 2 replies
  • 1011 views

I am thinking of turning on ADC with DMA when analog watchdog detect certain level of signal. Then I would like to turn on ADC with only watchdog first and when LevelOutOfWindowCallback() is called ADC with DMA starts. I tried code below but it didn't work. It seems that watchdog never started or worked.

Please teach me how to do that.

Thank you.

int main(void){

configurations

HAL_ADC_Start(&hadc1);

 ADC1->CR1|=(1<<23);

 ADC1->CR1|=(1<<1);

 ADC1->SR &= ~(1 << 0);

 HAL_TIM_Base_Start(&htim2);

while(1){

}

}

void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc){

HAL_ADC_Start_DMA(&hadc1,(uint32_t*)DMA_buf,sizeof(DMA_buf)/sizeof(DMA_buf[0]));

}

This topic has been closed for replies.

2 replies

S.Ma
Principal
September 6, 2021

If you use hal, use it too for watchdog interrupt too. And if you only need to trigger a range, DMA maybe only needed if you use ADC data as multichannel reading.

SShir.2
SShir.2Author
Associate II
September 6, 2021

Thank you.

Just simply writing like below Both DMA and analog watchdog works. This is okay though, my ideal is to use ADC and watchdog separately. So I don't need any data which is out of threshold. So I would like to trigger to start DMA by LevelOutOfWindowCallback() . But when I only write HAL_ADC_Start_IT(&hadc1), LevelOutOfWindowCallback() is not called but when I write both  HAL_ADC_Start_IT and HAL_ADC_Start_DMA. Is it possible to use only watchdog first without using DMA ?

 HAL_ADC_Start_IT(&hadc1);

 HAL_ADC_Start_DMA(&hadc1,(uint32_t*)DMA_buf,sizeof(DMA_buf)/sizeof(DMA_buf[0]));