2018-03-18 04:25 PM
Hello guys.
I've recently downloaded ST standard libraries for stm8s series and working with the functions.
In cube mx version when we called an interrupt the callback function automatically was executed and after that, the flag was cleared in IRQ HANDLER function at the end of the interrupt.
But in the standard library for stm8 I can't find any functions that have the flag clearing in the interrupts.
Would you please explain me how can I manage this?
2018-03-21 12:42 AM
Hello dhenry,
There is no such problem in ST library. If we refer to the EXTI handler, we can see such code:
/**
* @brief This function handles EXTI line 4 to 15 interrupts.
*/
void EXTI4_15_IRQHandler(void)
{
/* USER CODE BEGIN EXTI4_15_IRQn 0 */
/* USER CODE END EXTI4_15_IRQn 0 */
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8);
/* USER CODE BEGIN EXTI4_15_IRQn 1 */
/* USER CODE END EXTI4_15_IRQn 1 */
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
We can enter user code either before HAL_GPIO_EXTI_IRQHandler() function, which clears the flag or after it.
And if we refer to body of
HAL_GPIO_EXTI_IRQHandler() function, we see again that flag is cleared before HAL_GPIO_EXTI_Callback(), which can be reimplemented by user for example in main.c.
/**
* @brief This function handles EXTI interrupt request.
* @param GPIO_Pin: Specifies the pins connected to the EXTI line.
* @retval None
*/
void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin)
{
/* EXTI line interrupt detected */
if(__HAL_GPIO_EXTI_GET_IT(GPIO_Pin) != RESET)
{
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
HAL_GPIO_EXTI_Callback(GPIO_Pin);
}
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?
Regards
Szymon
2018-03-21 06:55 AM
thanks. sounds like the notion of the SPL clearing the flag at the end of an isr is simply wrong.
2018-03-22 05:38 AM
This would be important if we are for example receiving data that if the flag is not cleared at first so the data will be missed.But in my case just there is a button to communicate with the user that is not so speedy that data communication is.
Philipp said that I can use a capacitor to reduce bouncing of the push buttons.Do you have any references that explained how to place this cap or any data about this matter?
And if we refer to body of
HAL_GPIO_EXTI_IRQHandler() function, we see again that flag is cleared before HAL_GPIO_EXTI_Callback(), which can be reimplemented by user for example in main.c.
Yo are right about this matter, but I think you can cut that call back function and just place it after clearing the flag.
But the matter is that when you clear the flag at first, so what happens to the last interrupt occurred?In this matter, the last interrupt will be missed?
2018-03-22 05:56 AM
Something that I forgot to mention is that in stm8s as Szymon Panecki mentioned there are no registers for pending interrupts.But I think that in this case the flag or whatever it is(that we don't have access to) is automatically cleared as soon as the interrupt has occurred.The reason is that if it was cleared at the end of the interrupt routine if I put a delay the next interrupt wouldn't occur till the delay is passed, but after even some seconds delay the interrupt is generated every time pushing the push button.
Am I right?
2018-03-22 10:23 AM
'
How can it be possible that there be no flags for the external interrupt?There must be some flags that the MCU finds out that the interrupt occurred.'
the exti module across ST's mcu offerings is the worst I have ever seen - that's to put it super-mildly. Essentially you have to track which pins may have triggered the ISR manually. Other vendors use a flag to indicate that - as you would expect.
would be interesting to see how ST settled on this approach.