cancel
Showing results for 
Search instead for 
Did you mean: 

ADC injected mode can't interrupt?

Lzhiy.1
Associate II

I try to transplant the Three-Shunt FOC project based on STM32G431RB supported by MCSDK to STM32G431C8.

But The ADC interrupt is never called.I comment the code below in function R3_2_ADCxInit,the interrupt works.

LL_ADC_INJ_SetQueueMode( ADCx, LL_ADC_INJ_QUEUE_2CONTEXTS_END_EMPTY );

the code set bit JQM of ADC->CFGR,

the reference manual refers:

"If JQM = 1, the Queue can be empty after the end of an injected sequence or if the

Queue is flushed. When this occurs, there is no more context in the queue and

hardware triggers are disabled. Therefore, any further hardware injected triggers

are ignored until the software re-writes a new injected context into JSQR register."

in the timer update interrupt function:

void  R3_TIMx_UP_IRQHandler(void)
{
 
  ADC1->JSQR = PWMC_R3_Handle.ADCConfig1[PWMC_Handle.Sector] | (uint32_t) PWMC_R3_Handle.ADC_ExternalPolarityInjected;
  ADC2->JSQR = PWMC_R3_Handle.ADCConfig2[PWMC_Handle.Sector] | (uint32_t) PWMC_R3_Handle.ADC_ExternalPolarityInjected;
	
  //LL_TIM_CC_EnableChannel(TIM1, LL_TIM_CHANNEL_CH4);
  LL_TIM_SetTriggerOutput(TIM1, LL_TIM_TRGO_OC4REF);
  PWMC_R3_Handle.ADC_ExternalPolarityInjected = (uint16_t)LL_ADC_INJ_TRIG_EXT_RISING;	
}

I have "re-write a new injected context into JSQR register."in the update interrupt.But no interrupt is generated from the beginning and after 4 writing operations,the JQOVF(Injected context queue overflow) is set,the bit JEOS is never set,the bit ADRDY(ADC ready) is always set.

When I reset the JQM bit,JEOS is set,but still no interrupt is generated.I add "HAL_ADCEx_InjectedStart(&hadc1);" after the initialization of the motor.The interrupt is generated as expect.

But I've seen the single-shunt and three-shunt project generated by MCSDK,the JQM bit is always set.What steps have I missed?

​---------------------------------

I set the JQM=1,and find in the function "R3_TIMxInit"

LL_TIM_SetTriggerOutput(TIM1, LL_TIM_TRGO_RESET);

and then in the function above:R3_TIMx_UP_IRQHandler.

ADC->JSQR is set,and then the trigger is set to

LL_TIM_SetTriggerOutput(TIM1, LL_TIM_TRGO_OC4REF);

I replace the trriger souce in function R3_TIMxInit to LL_TIM_TRGO_OC4REF,the interrupt is generated.

So the issue is when the trigger source is LL_TIM_TRGO_RESET,and ADC->JSQR is written,the injected interrupt won't be generated.What's the reason?

0 REPLIES 0