Skip to main content
OUnsa
Associate II
November 29, 2019
Question

SysTick Interrupt is blocking GPIO Interrupt

  • November 29, 2019
  • 2 replies
  • 1442 views

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

This topic has been closed for replies.

2 replies

Pavel A.
Super User
November 29, 2019

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

-- pa

Clive1 (HNL)
Explorer
November 29, 2019

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.

OUnsa
OUnsaAuthor
Associate II
November 29, 2019

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.

Clive1 (HNL)
Explorer
November 29, 2019

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