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

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

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

Jump to solution
1,223 Views
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.

Tags (4)
0 Kudos
Reply
1 Solution
1,168 Views
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

View solution in original post

0 Kudos
Reply
3 Replies
1,199 Views
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 Kudos
Reply
1,182 Views
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 Kudos
Reply
1,169 Views
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 Kudos
Reply