Good afternoon ladies and gentlemen.
I've been trying to put analog read to work and been partially successful.
First of all I tried using CubeMX for generating most of the init code and in "manual pull mode" everything works fine:
if (HAL_ADC_PollForConversion(&hadc1, 10000) == HAL_OK)
ADC_val = HAL_ADC_GetValue(&hadc1);
hadc1.Init.ContinuousConvMode = ENABLE;
But I want to have this working via callback function that is described in many places. In CubeMX I set up pretty much everything I could find, especially inside NVIC -> ADC1 and ADC2 global interrupts. Got all the generated code and implemented weak methods as necessary
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
ADC_val = HAL_ADC_GetValue(hadc);
// I'm not sure about this one cause I cannot see any override reference calls to this one! Something changed recently?
IRQs are set properly in the generated code:
static void MX_NVIC_Init(void)
/* ADC1_2_IRQn interrupt configuration */
HAL_NVIC_SetPriority(ADC1_2_IRQn, 0, 0);
Also I start ADC with suggested HAL_ADC_Start_IT(&hadc1); call.
What happens is that the HAL_ADC_ConvCpltCallback is called only once, and not whenever I touch my rotation sensor. So it seems like IRQ handler is not properly registered but after several hours I cannot figure out what's up.
Anyone has suggestions?
P.S. For the sake of stupid test, I put the HAL_ADC_Start_IT(&hadc1); within the while loop and it started triggering every time, but this is of course stupid and shouldn't be like that. Full source of my main file can be seen here: