cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass a variable read in an interruption to main()

amelendez
Associate III
Posted on June 14, 2017 at 15:14

I'm reading a serial ADC from an interruption (24 bits)

I need to pass its read value to the main()

I have defined in /* USER CODE BEGIN PV */ a volatile variable uint32_t  xxxxx

The xxxxx variable is right inside the interruption routine but it becomes 0x01FFFFFE when called in main()

How can I pass the xxxxx variable from       void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)     to      main()?

12 REPLIES 12
Posted on June 15, 2017 at 15:10

Debugging the hardware, I have seen that after executing the execution of 'for' loop into callback function, the 'for' loop runs again.

It seems like that  the interruption happened again.

But I watch on the oscilloscope that the DATAin line has not gone down (then, none interruption should happen)

DATAin line is use to interrupt the micro (first DATAin goes down, then DATAin delivers 24 data bits every clock pulse)

Posted on June 15, 2017 at 15:15

I think I should disable the interruption once it has begun and after exiting, to enable it again

Posted on June 15, 2017 at 15:15

Sorry:

I think I should disable the interruption once it has begun and BEFORE exiting, to enable it again