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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

ソリューションへジャンプ
1,186件の閲覧回数
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 解決策
1,131件の閲覧回数
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 返答(返信)
1,162件の閲覧回数
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 件の賞賛
返信
1,145件の閲覧回数
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 件の賞賛
返信
1,132件の閲覧回数
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 件の賞賛
返信