[i.MX RT1040 EVK] SAI EDMA Local Loopback Issue: RX buffer data shifted by 4 bytes

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

[i.MX RT1040 EVK] SAI EDMA Local Loopback Issue: RX buffer data shifted by 4 bytes

866 Views
nikonz66
Contributor I

Hi NXP Team,

I am currently working on the official i.MX RT1040 EVK and trying to use the SAI interface for custom pure data transfer (not standard audio). To verify my logic, I am performing a Local Loopback Test by physically shorting the SAI TX and RX pins on the EVK, completely bypassing the external audio codec.I want to use the I2S (SAI) interface as a high-speed communication peripheral for pure data transfer (not standard audio) and encapsulate it into a custom communication driver layer. I am currently in the testing phase verifying the basic logic.

I initialized the SAI to work in classic I2S master mode (generating BCLK and SYNC internally) and used SAI_TransferSendEDMA() and SAI_TransferReceiveEDMA() with a buffer size of 128 bytes.

When I populate my tx_buffer starting with 0xAA (e.g., [0xAA, 0x01, 0x02, ...]) and start the DMA transfers, the rx_buffer receives the data, but the entire payload is shifted by 4 bytes. Specifically:

1   rx_buffer[0] to rx_buffer[3] are always 0x00.

2   My actual first byte 0xAA appears at rx_buffer[4].

3   The rest of the data follows sequentially, which means the last 4 bytes of my payload are truncated/lost because the DMA transfer size is strictly 128 bytes.

(Please see the attached Keil debug screenshot showing the tx_buffer and rx_buffer memory windows.)
Any guidance or reference code would be greatly appreciated. Thank you!

0 Kudos
Reply
1 Reply

789 Views
nikonz66
Contributor I

solved
If both the transmitter and receiver use the transmitter bit clock and frame sync:
• Configure the transmitter for asynchronous operation and the receiver for
synchronous operation.
• Enable the receiver in synchronous mode only after both the transmitter and receiver
are enabled.
• Enable the transmitter last and disable the tranmitter first.

%3CLINGO-SUB%20id%3D%22lingo-sub-2331478%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%5Bi.MX%20RT1040%20EVK%5D%20SAI%20EDMA%20Local%20Loopback%20Issue%3A%20RX%20buffer%20data%20shifted%20by%204%20bytes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2331478%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20NXP%20Team%2C%3C%2FP%3E%3CP%3EI%20am%20currently%20working%20on%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eofficial%20i.MX%20RT1040%20EVK%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eand%20trying%20to%20use%20the%20SAI%20interface%20for%20custom%20pure%20data%20transfer%20(not%20standard%20audio).%20To%20verify%20my%20logic%2C%20I%20am%20performing%20a%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3ELocal%20Loopback%20Test%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eby%20physically%20shorting%20the%20SAI%20TX%20and%20RX%20pins%20on%20the%20EVK%2C%20completely%20bypassing%20the%20external%20audio%20codec.%3CSPAN%3EI%20want%20to%20use%20the%20I2S%20(SAI)%20interface%20as%20a%20high-speed%20communication%20peripheral%20for%20pure%20data%20transfer%20(not%20standard%20audio)%20and%20encapsulate%20it%20into%20a%20custom%20communication%20driver%20layer.%20I%20am%20currently%20in%20the%20testing%20phase%20verifying%20the%20basic%20logic.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EI%20initialized%20the%20SAI%20to%20work%20in%20classic%20I2S%20master%20mode%20(generating%20BCLK%20and%20SYNC%20internally)%20and%20used%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22%22%3ESAI_TransferSendEDMA()%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eand%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3ESAI_TransferReceiveEDMA()%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ewith%20a%20buffer%20size%20of%20128%20bytes.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EWhen%20I%20populate%20my%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Etx_buffer%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Estarting%20with%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E0xAA%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E(e.g.%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%5B0xAA%2C%200x01%2C%200x02%2C%20...%5D)%20and%20start%20the%20DMA%20transfers%2C%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Erx_buffer%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ereceives%20the%20data%2C%20but%26nbsp%3Bthe%20entire%20payload%20is%20shifted%20by%204%20bytes.%20Specifically%3A%3C%2FP%3E%3CP%3E1%26nbsp%3B%20%26nbsp%3Brx_buffer%5B0%5D%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Erx_buffer%5B3%5D%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eare%20always%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E0x00.%3C%2FP%3E%3CP%3E2%26nbsp%3B%20%26nbsp%3BMy%20actual%20first%20byte%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E0xAA%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eappears%20at%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Erx_buffer%5B4%5D.%3C%2FP%3E%3CP%3E3%26nbsp%3B%20%26nbsp%3BThe%20rest%20of%20the%20data%20follows%20sequentially%2C%20which%20means%20the%20last%204%20bytes%20of%20my%20payload%20are%20truncated%2Flost%20because%20the%20DMA%20transfer%20size%20is%20strictly%20128%20bytes.%3C%2FP%3E%3CP%3E(Please%20see%20the%20attached%20Keil%20debug%20screenshot%20showing%20the%20tx_buffer%20and%20rx_buffer%20memory%20windows.)%3CBR%20%2F%3EAny%20guidance%20or%20reference%20code%20would%20be%20greatly%20appreciated.%20Thank%20you!%3CEM%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FEM%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2332262%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20%5Bi.MX%20RT1040%20EVK%5D%20SAI%20EDMA%20Local%20Loopback%20Issue%3A%20RX%20buffer%20data%20shifted%20by%204%20bytes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2332262%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3Esolved%3CBR%20%2F%3EIf%20both%20the%20transmitter%20and%20receiver%20use%20the%20transmitter%20bit%20clock%20and%20frame%20sync%3A%3CBR%20%2F%3E%E2%80%A2%20Configure%20the%20transmitter%20for%20asynchronous%20operation%20and%20the%20receiver%20for%3CBR%20%2F%3Esynchronous%20operation.%3CBR%20%2F%3E%E2%80%A2%20Enable%20the%20receiver%20in%20synchronous%20mode%20only%20after%20both%20the%20transmitter%20and%20receiver%3CBR%20%2F%3Eare%20enabled.%3CBR%20%2F%3E%E2%80%A2%20Enable%20the%20transmitter%20last%20and%20disable%20the%20tranmitter%20first.%3C%2FP%3E%3C%2FLINGO-BODY%3E