cancel
Showing results for 
Search instead for 
Did you mean: 

SDIO IRQ does not work with GPIO interrupt

megahercas6
Senior
Posted on April 28, 2017 at 20:51

Hello, writing support library for my dev board, and i run into the problem.

I have simple txt file generated by Print_SD() function.

If this function is called from mains, it does produce TEST.TXT file, no problems

But if i map this function to GPIO interrupt, and call Print_SD() function from IRQ program, it simply hangs. It looks like it is preventing functions to be executed:

void SDIO_IRQHandler(void);

void SD_SDIO_DMA_IRQHANDLER(void);

How can i fix this ? SDIO does have higher priority, so why it should hang ?

void NVIC_Config(void) //SDIO

{

  NVIC_InitTypeDef NVIC_InitStructure;

  /* Configure the NVIC Preemption Priority Bits */

  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

  NVIC_InitStructure.NVIC_IRQChannel = SDIO_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);

  NVIC_InitStructure.NVIC_IRQChannel = SD_SDIO_DMA_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;

  NVIC_Init(&NVIC_InitStructure);  

}

void Button_IRQ_Config(void)

{

  /* SW1 PJ5 | SW2 PB10 */

 

  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;  

  EXTI_InitStructure.EXTI_LineCmd = ENABLE;

 

  EXTI_InitStructure.EXTI_Line = EXTI_Line5;

  EXTI_Init(&EXTI_InitStructure);

  EXTI_InitStructure.EXTI_Line = EXTI_Line10;

  EXTI_Init(&EXTI_InitStructure);

 

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0xF;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0xF;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

 

  NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;

  NVIC_Init(&NVIC_InitStructure);

 

  NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;

  NVIC_Init(&NVIC_InitStructure);

}

#ftfs #sdio #fat32 #irq #gpio
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on April 28, 2017 at 21:34

With 

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); or something more appropriate?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

7 REPLIES 7
Posted on April 28, 2017 at 21:03

Unless I'm mistaken you've selected one bit for premption level, and you only have 4 bits total to work with. Setting 0xF/0xF is counter productive. Select a 2/2-bit split, and configure the 'don't care' interrupt with 0x3/0x3

Writing data to the SD from an interrupt is probably something best avoided, it will block for a long while, buffer the data, and write in a worker thread, so you can serialize access to FatFs and SDIO.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
megahercas6
Senior
Posted on April 28, 2017 at 21:22

Hi,

I try to run with different values, but did not helped, try one higher, one lower, Other way around, same, it is still hanging...
Posted on April 28, 2017 at 21:34

With 

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); or something more appropriate?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on April 28, 2017 at 21:37

Hey, it did the trick, i was only changing sub- priority 

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);  //placed before GPIO NVIC config
David Henretty
Associate II
Posted on July 31, 2017 at 16:17

Hi,

Sorry to 'piggyback' on this question but where can I find the implementation of NVIC_PriorityGroupConfig() and the definition of NVIC_PriorityGroup_4 ?

The FreeRTOS website states that this call is required when using the STM32 Driver Library with FreeRTOS but I cannot find it in either the Driver Library or the CMSIS code that is generated when creating a project using STM32CubeMX. Reference is, however, made to it from stm32f7xx_hal_cortex.c in the header documentation for the function HAL_NVIC_EnableIRQ().

Is this no longer required on STM32F7 and only required for M3/M4 ?

Any clarification would be appreciated.

David

David Henretty
Associate II
Posted on July 31, 2017 at 18:18

Thanks Jan !

With that pointer, I was able to find NVIC_PRIORITYGROUP_4 too.

I should have searched without case sensitivity on !!!

David

Posted on July 31, 2017 at 17:05

NVIC_PriorityGroupConfig() is the SPL's version of CMSIS's standard NVIC_SetPriorityGrouping(). Cube has another one, HAL_NVIC_SetPriorityGrouping().

JW