_io_read in interrupts

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

_io_read in interrupts

631 Views
billnd
Contributor IV

Is it safe to use _io_read functions from an interrupt if IO_SERIAL_NON_BLOCKING has been set? Documentation is a bit ambiguous.

2 Replies

261 Views
Luis_Garabo
NXP TechSupport
NXP TechSupport

Hi Billnd,

The best practice for interrupt is to just flag or signalize something (semaphore, mutex, etc) you shall not execute functions. The stack accumulation could cause a stack overflow in the stack level. I would recomend to start a high priority task that just goes and read when you receive an interruption. The isr will just start the task. Then the task will go, read and go back to sleep.

I hope this helps you.

Regards,

Garabo

261 Views
RadekS
NXP Employee
NXP Employee

As Garabo said, it is not correct approach (use _io_read functions from an interrupt).

In fact, there also depends on IO driver implementation.

It is obvious that IO drivers which using interrupts cannot be used inside interrupt routine – for example SPI driver in MQX4.0.2.

Some of IO drivers could work when pooling method is used in driver – for example Legacy SPI driver in MQX4.0.2 but this is rather side effect of trivial implementation of this driver.

So, general recommendation is not to use _io_read functions from an interrupt.