How to Evaluate the Efficiency Difference Between Synchronous and Asynchronous LPSPI Transfers

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

How to Evaluate the Efficiency Difference Between Synchronous and Asynchronous LPSPI Transfers

跳至解决方案
795 次查看
malove
Contributor IV

Hello,

Previously, our scheduler called the Lpspi_Ip_SyncTransmit() function every 10ms to perform SPI communication in polling mode, as shown below:

while True:
    if 10ms_flag_on:
        Lpspi_Ip_SyncTransmit();
         
     

 

Recently, we switched to an interrupt-driven approach using LPSPI0_IRQn with Lpspi_Ip_AsyncTransmit(), as shown below:

 

While True:
    if 10ms_flag_on:
        Lpspi_Ip_AsyncTransmit();

 

I would like to ask if there is any recommended or reliable method to quantitatively evaluate the efficiency difference between the synchronous and interrupt-based asynchronous transmission methods.

Thank you in advance for your support.

标记 (4)
0 项奖励
回复
1 解答
740 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

synchronous methods might use more CPU resources due to continuous polling, can block the main loop or delay other peripherals, whereas asynchronous methods might be more efficient by leveraging interrupts. To compare Lpspi_Ip_SyncTransmit() and Lpspi_Ip_AsyncTransmit() without an RTOS, you can:

- Measure execution time using the DWT cycle counter.
- Mark timing with GPIO toggles for oscilloscope/logic analyzer.
- Estimate CPU load by counting idle loop iterations.
- Assess responsiveness by measuring interrupt latency during SPI activity.

BR, Petr

在原帖中查看解决方案

0 项奖励
回复
3 回复数
771 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

you can measure the time taken for data transmission from start to finish for both methods. This can be e.g. done using high-resolution timers to capture the precise duration of each transmission.
In RTOS system you can refer to below
https://community.nxp.com/t5/S32-Design-Studio-Knowledge-Base/HOWTO-Use-FreeRTOS-OS-Awareness-with-S...
https://mcuoneclipse.com/2019/12/31/implementing-freertos-performance-counters-on-arm-cortex-m/

BR, Petr

0 项奖励
回复
754 次查看
malove
Contributor IV

Thank you for your response.

In addition to the execution time, I would also like to evaluate the efficiency of the two approaches in other aspects, such as CPU load, system responsiveness, or potential blocking impacts on other tasks.

Are there any recommended methods, tools, or metrics to assess these factors, especially in an environment without an RTOS?

0 项奖励
回复
741 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

synchronous methods might use more CPU resources due to continuous polling, can block the main loop or delay other peripherals, whereas asynchronous methods might be more efficient by leveraging interrupts. To compare Lpspi_Ip_SyncTransmit() and Lpspi_Ip_AsyncTransmit() without an RTOS, you can:

- Measure execution time using the DWT cycle counter.
- Mark timing with GPIO toggles for oscilloscope/logic analyzer.
- Estimate CPU load by counting idle loop iterations.
- Assess responsiveness by measuring interrupt latency during SPI activity.

BR, Petr

0 项奖励
回复