cancel
Showing results for 
Search instead for 
Did you mean: 

SysTick Interrupt is blocking GPIO Interrupt

OUnsa
Associate II

Hi,

I am having following problem. I am reading all the GPIO pins of portB when I receive an interrupt. The interrupt rate is 625KHz and I am storing this data for 20ms.

The problem is I have data losses every 1ms. I think this happens because of the SysTick interrupt.

My code is really simple. I only activate one GPIO pin for interrupts and the whole PORTB as an Input. I am not enabling the other perpiherals.

Does anyone have an idea how can I solve this problem? I need to store data without data losses.

Kind regards

Ozan

7 REPLIES 7
Pavel A.
Evangelist III

Try thinking about it for ~ 10 minutes and you'll get an idea.

-- pa

Clive1 (HNL)
Senior II

SysTick should be fairly brief, how much blocking is it doing?

You can *change* the priorities if they don't suit you. Be aware that SysTick / HAL_IncTick() needs to be functioning with high priority and preemption otherwise HAL_Delay() / HAL_GetTick() will have deadlocking issues in interrupt/callback context because the counter ceases to advance.

The CPU can saturate with interrupts if the loading gets too high.

Consider using TIM/DMA to sample GPIO at a paced sample rate.

It seems it is periodic and occurs every ms. It blocks the occurrence of GPIO interrupt for about 4us. I have already tried to change the priority of SysTick interrupt but this blocking still occurs. I couldn't figure what else can cause this.

Can increase latency as it pushes/pops context.

If GPIO interrupt is critical, it would need to preempt others.

Lowest latency/jitter would be achieved by DMA

I tried to use DMA but I think I am doing something wrong. I configured DMA generator with external request signal with CubeMX. However, I am doing something wrong I guess. I cannot observe any interrupt and data. Probably I am doing something wrong. I will be glad if you have some examples for this.

> ... I think I am doing something wrong. ... I am doing something wrong I guess. ... Probably I am doing something wrong. ...

Your "MCU" has memory problems!

Assuming you're using STM32WB and CubeMX, not really converging with anything I'm using. I don't have the resources/bandwidth to write sample code.

Perhaps review the HAL examples ST provides, and see if the logic/behaviour can be deduced from the Reference Manual.

For commercial designs engage with the FAE assigned to your account.

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