Start SPI transfer in interrupt service routine

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Start SPI transfer in interrupt service routine

跳至解决方案
1,843 次查看
michelhayoz
Contributor I

Hello

I am reading values from an ADC via SPI with a sampling rate of 1kHz. The ADC has a data-ready signal on which the SPI transfer has to be started. Is there a way to initiate the SPI transfer inside the interrupt service routine of the data-ready signal (gpio interrupt) because a synchronisation with a MQX task is too slow (MQX tick is 5ms). I am using MQX4.2 running on the Vybrid VF61 Cortex M4.

Thank you in advance for your response.

Kind regards

Michel Hayoz

0 项奖励
回复
1 解答
1,570 次查看
danielchen
NXP TechSupport
NXP TechSupport

Hi Michel Hayoz

I think it is possible to initiate the SPI transfer with an ISR.

Yes, the ADC driver of MQX is not able to sample at high frequency, as you said, the minimum sampling period is 5 ms because this is the TICK timer period of the RTOS.   Therefore, in order to have a high sampling rate, it will be required to add a "bare-board" ADC driver inside MQX RTOS, and bypassing the ADC interrupt from MQX for using the "bare-board" interrupt.

If you want that MQX handle all the ISR process you can use _int_install_isr. Using this function MQX catches all hardware interrupts in the range that the BSP defined and saves the context of the active task. For most interrupts, MQX calls the ISR that is stored in the interrupt vector table at the location identified by its interrupt vector number. The disadvantage with this is the interrupt latency is longer and depends completely on MQX.

The other option is using _int_install_kernel_isr. Some real-time applications need special event handling to occur outside the scope of MQX. The need might arise that the latency in servicing an interrupt be less than the MQX interrupt latency. If this is the case, an application can use _int_install_kernel_isr(0 to bypass MQX and let the interrupt be serviced immediately.

A kernle ISR cannot call MQX functions. However, it can put data in global variables, which a task can access.

Have a great day,

Daniel

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button or helpful. Thank you!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,571 次查看
danielchen
NXP TechSupport
NXP TechSupport

Hi Michel Hayoz

I think it is possible to initiate the SPI transfer with an ISR.

Yes, the ADC driver of MQX is not able to sample at high frequency, as you said, the minimum sampling period is 5 ms because this is the TICK timer period of the RTOS.   Therefore, in order to have a high sampling rate, it will be required to add a "bare-board" ADC driver inside MQX RTOS, and bypassing the ADC interrupt from MQX for using the "bare-board" interrupt.

If you want that MQX handle all the ISR process you can use _int_install_isr. Using this function MQX catches all hardware interrupts in the range that the BSP defined and saves the context of the active task. For most interrupts, MQX calls the ISR that is stored in the interrupt vector table at the location identified by its interrupt vector number. The disadvantage with this is the interrupt latency is longer and depends completely on MQX.

The other option is using _int_install_kernel_isr. Some real-time applications need special event handling to occur outside the scope of MQX. The need might arise that the latency in servicing an interrupt be less than the MQX interrupt latency. If this is the case, an application can use _int_install_kernel_isr(0 to bypass MQX and let the interrupt be serviced immediately.

A kernle ISR cannot call MQX functions. However, it can put data in global variables, which a task can access.

Have a great day,

Daniel

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button or helpful. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
1,570 次查看
michelhayoz
Contributor I

Hello Daniel Chen

Thank you for your answer. This means that I have to modify the DSPI driver of MQX ? Because there are wait statements for semaphores in the driver routines even if the driver is interrupt driven.

Kind regards,

Michel Hayoz

0 项奖励
回复
1,570 次查看
danielchen
NXP TechSupport
NXP TechSupport

Yes, semaphores cannot be used within an ISR.

Regards

Daniel

0 项奖励
回复