AnsweredAssumed Answered

Basic help on ISR's and the HAL

Question asked by johnson.thor on Jul 15, 2016
Latest reply on Jul 21, 2016 by johnson.thor

I'm trying to kick off the ADC via Timer1 at 9600 sps for 4 channels.

I have it all working -- once, but I think I'm (ab)using the HAL wrong;

I tried to put the kick off code in a function in main called

HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim)
, but that never got called.

I then relocated it to the TIM1_BRK_UP_TRG_COM_IRQHandler like this:

void TIM1_BRK_UP_TRG_COM_IRQHandler(void)
{
  /* USER CODE BEGIN TIM1_BRK_UP_TRG_COM_IRQn 0 */
     
    //--This only gets called once?
    //Trigger a LED Pin so I can see the frequency (should be 9600)
    HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_9);
     
    //Tell the ADC to start a scan and populate it.
    HAL_ADC_Start_DMA(&hadc, (uint32_t *)&adc[1], 4);
     
    //We catch the end of AD Conversion in the ADCScanCompleted interrupt.
     
  /* USER CODE END TIM1_BRK_UP_TRG_COM_IRQn 0 */
  HAL_TIM_IRQHandler(&htim1);
  /* USER CODE BEGIN TIM1_BRK_UP_TRG_COM_IRQn 1 */
 
  /* USER CODE END TIM1_BRK_UP_TRG_COM_IRQn 1 */
}

But that only gets called once (when I execute HAL_TIM_Base_Start_IT(&htim1) in main), not every 5000 counts.

What am I missing (Keil uVision 5.3)?

Update:  I got it repeating (I had Prescalar and Period mixed up from the cube).  But I still don't know why I have to put the code in the ISR and not in a Callback...

 

Outcomes