2018-06-14 07:32 AM
I am debugging my camera application which doesn't render correctly (STM32 F746 discovery board + STM32 F4 DIS-CAM).
To find the error, I want to count the number of DCMI Line and Frame interrupts and check if numbers match/make sense.
My attemt to do this was adding the _HAL_DCMI_GET_IT_SOURCE() to the DCMI_IRQHanlder() and increasing a counter every time a line or a frame interrupt occurs. I don't understand how this macro works, what does it return?
The documentation (I've read it all: DCMI AN5020, HAL UM1905) says that the macro returns ''the state of interrupt'', what does this mean? What is the best and/or the simplest way to count mentined interrupts?#macro #stm32f7-hal-dcmi #dcmi2018-06-21 06:06 AM
I figured it out eventually. If anyone finds my explanation useful:
The macro is defined in STM32CUBE/../Drivers/HAL/Inc/stm32f7xx_hal_dcmi.h
It takes two arguments: __HANDLE__ which is the DCMI Handle, and __INTERRUPT__ which is the interrupt you're interested in.
For example, if you want to do something on every LINE interrupt:
DCMI_HandleTypeDef hDcmiHandler;
/**
* DCMI global interrupt handler (DCMI_IT).
*/
void
DCMI_IRQHandler
(
void
)
{
// Line interrupt
if
(
__HAL_DCMI_GET_IT_SOURCE
(
&
hDcmiHandler, DCMI_IT_LINE)
==
SET)
{
// Do something ...
}
}
As explained in the
at chapter 3.8 DCMI Interrupts, there are several interrupts/flags related to the DCMI operation, but in code they all trigger the same 'global' DCMI interrupt.The global DCMI interrupt handler is void DCMI_IRQHandler(void) in HAL = this is the 'IT_DCMI' from Figure 32. DCMI interrupts and registers.
Individual interrupts (such as IT_LINE or IT_FRAME) are defined in STM32CUBE/Drivers/HAL/../Inc/stm32f7xx_hal_dcmi.h
The macro returns ITStatus SET or RESET defined in STM32CUBE/Drivers/CMSIS/.../Include/stm32f7xx.h, which is essentialy just 1 or 0.
So if the line interrupt (DCMI_IT_LINE) is the thing that triggered the DCMI global interrupt, then the macro will return 1. If not, it will return 0.