AM2612: AM2612 SPI read parallel question

Part Number: AM2612

Hi experts,

 

I am asking for customer.

Customer's application scenario: The customer needs to use 2 SPI modules to read 6 channels of magnetic encoder results. The motor control algorithm requires the reading to be completed within 30 µs. Each SPI module handles 3 chip selects (2 hardware chip selects + 1 software chip select), and everything must be completed within the same ADC interrupt, meaning SPI cannot use interrupts.

The customer tested both MCAL and SDK:

  • A single SPI read of 6 bytes takes 25 µs (MCAL) and 7 µs (SDK)
  • The actual data transmission time on the bus is 5 µs

The preliminary conclusion is that only the SDK can meet the requirement. But even with SDK, reading 6 channels sequentially is not sufficient — it is necessary to read 2 channels in parallel each time to meet the timing requirement.

 

Customer's question is: Can the SDK support initiating communication on two SPI hardware units simultaneously (without using interrupts), and then polling to check the completion status of both channels? This would enable a 2×3 SPI read, with a theoretical total time of just over 21 µs, which can meet requirements.

 

Could you help to check and better give us a demo?

 

Best Regards

  • Hi Kita,

    Thank you for the detailed description of your customer's application requirements.

    Yes, the AM2612 SDK can support simultaneous SPI communication on two hardware modules with polling-based completion checking. Here's how to approach this:

    Parallel SPI Implementation Approach:

    1. Configure both SPI modules independently - Set up SPI0 and SPI1 (or your chosen modules) with identical timing parameters to handle 3 chip selects each (2 hardware CS + 1 software CS).

    2. Initiate transfers simultaneously - Use the SDK's non-blocking transfer APIs to start communication on both SPI modules back-to-back without waiting for completion:

      MCSPI_transfer(spi0Handle, &spi0Transaction);
      MCSPI_transfer(spi1Handle, &spi1Transaction);
    3. Poll for completion - Check the transfer status registers for both modules in a tight loop:

      while(!MCSPI_isTransferComplete(spi0Handle) || 
            !MCSPI_isTransferComplete(spi1Handle));
    4. Repeat for remaining chip selects - Execute this pattern three times (once per chip select group) to complete all 6 channel reads.

    Expected Timing:

    • Single 6-byte transfer: ~5 µs bus time + ~2 µs overhead = 7 µs
    • Parallel 2-channel read: ~7 µs per iteration × 3 iterations = ~21 µs total
    • This should meet your 30 µs requirement with margin

    Recommendations:

    • Ensure both SPI modules are clocked from the same source for synchronization
    • Use DMA if available to further reduce CPU overhead, though polling should be sufficient
    • Verify CS timing meets your magnetic encoder specifications

    Please let me know which SDK version you're using and if you need additional assistance implementing parallel SPI configuration and polling mechanism.

    Best Regards,
    Zackary Fleenor