IMX7D M4 ECSPI3 using SAI2 pads not working

Showing results for 
Search instead for 
Did you mean: 

IMX7D M4 ECSPI3 using SAI2 pads not working

Contributor I

Having trouble getting the ecspi3 to work out of the mikrobus connector on the sabre board rev D using FreeRTOS on the M4.

I am trying to set up ecspi3 with the m4 on the imx7d. When reading the ECSPI3_STATREG (0x30840018) register the module appears to be doing as expected, but we are not getting any data on the pads.   Here is how we have the registers configured:

We have read back these registers and verified that they are being set as expected.

We tried to initialize the ecspi3 using these steps:

1.  Cleared the EN bit in the ECSPI3_CONREG

     Set ECSPI3_CONREG = 0

2.  Enabled the clocks for ecspi3

     RDC_SetPdapAccess(RDC, rdcPdapEcspi3, 3 << (1 * 2), false, false);

     CCM_UpdateRoot(CCM, ccmRootEcspi3, ccmRootmuxEcspiOsc24m, 0, 0);

     CCM_EnableRoot(CCM, ccmRootEcspi3);
     CCM_ControlGate(CCM, ccmCcgrGateEcspi3, ccmClockNeededRunWait);

3.  Set the EN bit for the ECSPI3_CONREG

     Set ECSPI3_CONREG = 1

4.  Configure IOMUX for ECSPI3 external signals

     daisy registers:

     IOMUXC_ECSPI3_SCLK_SELECT_INPUT (0x30330544) = 1

     IOMUXC_ECSPI3_MISO_SELECT_INPUT (0x30330548) = 1


     IOMUXC_ECSPI3_SS0_B_SELECT_INPUT (0x30330550) = 1


     mux control pad registers:

     IOMUXC_SW_MUX_CTAL_PAD_SAI2_TX_SYNC (0x3033021C) = 1

     IOMUXC_SW_MUX_CTAL_PAD_SAI2_TX_BCLK (0x30330220) = 1

     IOMUXC_SW_MUX_CTAL_PAD_SAI2_RX_DATA (0x30330224) = 1

     IOMUXC_SW_MUX_CTAL_PAD_SAI2_TX_DATA (0x30330228) = 1

     we tried multiple variations of the pad control registers

5.  Configure registers for the ECSPI3 for the external SPI device

     .clockRate = get_ecspi_clock_freq((ECSPI_Type*)ECSPI3_BASE),
     .baudRate = 500000,
     .channelSelect = ecspiSelectChannel0,
     .mode = ecspiMasterMode,
     .burstLength = 7, /*24, /* don't know if this is correct */
     .clockPhase = ecspiClockPhaseSecondEdge,
     .clockPolarity = ecspiClockPolarityActiveLow,
     .ecspiAutoStart = FALSE

     ECSPI_CONREG_REG = 00F0B211

We are seeing in the ECSPI3_STATREG starts at being 3, when transmitting is 0 and then returns to 3, but nothing is happening on the O-scope looking at the mikrobus lines

Is there anything we are missing, or not setting up right?

Labels (1)
0 Kudos
1 Reply

NXP Employee
NXP Employee

Hi Andrew,

If you download FreeRTOS BSP from NXP web page you can find in the documentation forlder the "FreeRTOS_BSP_i.MX_7Dual_API_Reference_Manual". Here you can look at chapter 5.2.2 SPI initialization

The FreeRTOS BSP can be found here: > Software & Tools tab > FreeRTOS™ BSP for the i.MX 7Dual ARM® Cortex®-M4 core

Please note that you may use the .dtb file that provides m4 support, it is provided in the image FAT partition and you must change it in uboot console.

You may also verify that in the device tree the SPI is disabled so A7 will not configure the module and let M4 use it. Besides this check that the pins used by SPI are not being configured in the device tree as any other option. In this case you must delete such configuration. So, finally you will need to rebuild the dtb file and copy it to FAT partition of SDcard.


Note: If this post answers your question, please click the Correct Answer button. Thank you!

0 Kudos