GPIO interrupt slow down system

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GPIO interrupt slow down system

958 Views
Joshua_ZXR
Contributor II

Hi,

Now I am working on FRDM-K64F to implement frequency measurement. I have tried different method ( single edge capture mode, dual edge capture mode, and GPIO interrupt) , but all the results are not satisfactory.

One of my implementation is :

  • use GPIO detect rising edge (PTB9), GPIO IRQ has one action only : counter plus 1 
  • use FTM0 to count time : 5s
  • GPIO interrupt will be disabled once FTM0 5 seconds counting finish
  • according to counter number and timing (5s) to calculate frequency

base on my understanding, GPIO use system clock - 120MHz which could response faster interrupt.

but now I am facing an issue for this implementation. FTM interrupt can not be received once GPIO input signal frequency exceed 2.4MHz.

I think that because GPIO make system busy, so I change GPIO interrupt priority to 2 and set FTM interrupt priority to 1. In my opinion, GPIO interrupt should be preempted by FTM interrupt ( because FTM set to higher frequency). But the result is same as before :  FTM interrupt still can not be received once GPIO input signal frequency exceed 2.4MHz.

Then I have set GPIO interrupt to lower frequency -> 256, but the result no different.

It seems like, whole system has been occupied by GPIO interrupt once the input frequency higher than 2.4MHz, but it doesn't make sense....

Does anyone can give me a help ?

Thanks & Best Regards

Joshua 

Tags (1)
0 Kudos
3 Replies

905 Views
nxf77486
NXP TechSupport
NXP TechSupport

Hello @Joshua_ZXR ,

Ok is good to understand better your application, I would rather suggest to use Callback functions instead of the IRQ Handler for both cases GPIO and FTM, this could help us to optimize.

0 Kudos

938 Views
nxf77486
NXP TechSupport
NXP TechSupport

Hello @Joshua_ZXR ,

I have a couple question regarding your case, I will appreciate if you could answer them.

  1. Can you please explain I little bit more the logic, for my understanding you start the FTM  counting (for 5 seconds) after the GPIO rising edge interrupt, am I right? If don’t please explain.
  2. I understand also that this only happens when you are on 2.4MHz or above, so you are not facing this problem below this value? Just to make sure.
0 Kudos

929 Views
Joshua_ZXR
Contributor II

Hi @nxf77486 

Thank you for your fast response.

1) yes, FTM counter start after the first GPIO rising edge interrupt. In order to reduce ISR code size, a while loop has been used in the main thread to check counter value 

GPIO IRQ handler :

void BOARD_SW_IRQ_HANDLER(void)
{
    BOARD_INPUT_SIGNAL_PORT->ISFR = (1U << BOARD_INPUT_SIGNAL_PIN);
    //FTM_StartTimer(FTM_BASEADDR, kFTM_SystemClock);

    u32_cnt++;
}

main thread start FTM
while (0 == u32_cnt)
{
}

FTM_StartTimer(FTM_BASEADDR, kFTM_SystemClock);

is that because GPIO IRQ interrupt too frequent to stuck system in GPIO IRQ handler ? according to this understanding I have tried to start FTM in GPIO IRQ. But it will trigger hard fault ( bus fault) when function " FTM_StartTimer " be invoked in IRQ handler ...

2) Yes, the implementation working properly when input frequency <= 2.3MHz, and not working when input frequency >= 2.4MHz

 

Thanks & Best Regards

Joshua

0 Kudos