AnsweredAssumed Answered

CubeF1 ADC with DMA, DMA1_Channel1_IRQHandler interrupt is blocked by while() loop?

Question asked by sun.shawn on Jan 30, 2015
Latest reply on Feb 2, 2015 by sun.shawn
Attached is the project files,  CubeMX file is also in the package.
I just added some simple code in these 2 places. everything else is generated by CubeMX.

main.c, int main(void)
/* USER CODE BEGIN 3 */
   /* Infinite loop */
   while (1) {
       DMATC = 0;
       HAL_ADC_Start_DMA(&hadc1, (uint32_t *) adcValues, 5);
       HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET);    //for debug
       while(DMATC == 0)
       {
           ;
       }
       HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET);  //for debug
   }
 /* USER CODE END 3 */


stm32f1xx_it.c
void DMA1_Channel1_IRQHandler(void)
{
  /* USER CODE BEGIN DMA1_Channel1_IRQn 0 */
 
  /* USER CODE END DMA1_Channel1_IRQn 0 */
  HAL_DMA_IRQHandler(&hdma_adc1);
  /* USER CODE BEGIN DMA1_Channel1_IRQn 1 */
  if ( HAL_DMA_GetState( &hdma_adc1 ) == HAL_DMA_STATE_READY )
      DMATC = 1;
  /* USER CODE END DMA1_Channel1_IRQn 1 */
}


With the above while(DMATC == 0) loop in main.c the interrupt handler is never invoked, if I remove the while() loop in main.c then the interrupt is invoked.

What am I doing wrong? Maybe I missed some configuration ?

Thanks

Attachments

Outcomes