cancel
Showing results for 
Search instead for 
Did you mean: 

How does __HAL_DCMI_GET_IT_SOURCE() macro work?

Jur Div
Associate II
Posted on June 14, 2018 at 16:32

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?0690X0000060BXpQAM.png

#macro #stm32f7-hal-dcmi #dcmi
1 REPLY 1
Jur Div
Associate II
Posted on June 21, 2018 at 15:06

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 

https://www.st.com/content/ccc/resource/technical/document/application_note/group0/c0/ef/15/38/d1/d6/49/88/DM00373474/files/DM00373474.pdf/jcr:content/translations/en.DM00373474.pdf

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.