SPI MISO configuration for M4

Hi,
I am using ECSPI3 of M4 using given ecspi polling example code from uboot. I connected the SPI pins with a ADC IC. But I am always receiving zero. I checked with an oscilloscope and could see zero only. But when I remove the MISO pin from toradex evaluation board, I could see the ADC output in the oscilloscope. That is when the MISO pin is left free, I can see output of adc in oscilloscope but when it is connected with MISO pin C30 of evaluation board, the output is zero. I think the MISO pin is not configured properly. I am using the same code given in ecspi polling example but slightly converted it to freeRTOS. I didn’t change hardware_init() function. I am configuring ecspi as below,

void configure_ecspi_pins(ECSPI_Type* base)
{
	/* daisy chain selection */
	IOMUXC_ECSPI3_MISO_SELECT_INPUT = 0;  //(I2C1_SCL  SODIM 90)
	IOMUXC_ECSPI3_MOSI_SELECT_INPUT = 0;  //(I2C1_SCL  SODIM 90)

	/* iomux */
	IOMUXC_SW_MUX_CTL_PAD_I2C2_SCL = IOMUXC_SW_MUX_CTL_PAD_I2C2_SCL_MUX_MODE(3);    /* ECSPI SLK  */
	IOMUXC_SW_MUX_CTL_PAD_I2C1_SDA = IOMUXC_SW_MUX_CTL_PAD_I2C1_SDA_MUX_MODE(3);    /* ECSPI MOSI */
	IOMUXC_SW_MUX_CTL_PAD_I2C1_SCL = IOMUXC_SW_MUX_CTL_PAD_I2C1_SCL_MUX_MODE(3);    /* ECSPI MISO  */
	IOMUXC_SW_MUX_CTL_PAD_I2C2_SDA  = IOMUXC_SW_MUX_CTL_PAD_I2C2_SDA_MUX_MODE(3);     /* ECSPI SS0 */

	/* pad control */
	IOMUXC_SW_PAD_CTL_PAD_I2C2_SCL =    IOMUXC_SW_PAD_CTL_PAD_I2C2_SCL_PE_MASK  |
			IOMUXC_SW_PAD_CTL_PAD_I2C2_SCL_PS(0)    |      /* pull down */
			IOMUXC_SW_PAD_CTL_PAD_I2C2_SCL_DSE(0)   |
			IOMUXC_SW_PAD_CTL_PAD_I2C2_SCL_HYS_MASK;

	IOMUXC_SW_PAD_CTL_PAD_I2C1_SDA = IOMUXC_SW_PAD_CTL_PAD_I2C1_SDA_DSE(0)   |
			IOMUXC_SW_PAD_CTL_PAD_I2C1_SDA_HYS_MASK;

	IOMUXC_SW_PAD_CTL_PAD_I2C1_SCL = IOMUXC_SW_PAD_CTL_PAD_I2C1_SCL_HYS_MASK;

	IOMUXC_SW_PAD_CTL_PAD_I2C2_SDA  =  IOMUXC_SW_PAD_CTL_PAD_I2C2_SDA_PE_MASK   |
			IOMUXC_SW_PAD_CTL_PAD_I2C2_SDA_PS(3)     |      /* pull up */
			IOMUXC_SW_PAD_CTL_PAD_I2C2_SDA_DSE(0)    |
			IOMUXC_SW_PAD_CTL_PAD_I2C2_SDA_HYS_MASK;
}

Is this configuration correct? Also I am new to M4 controller and I am not having any ideas regarding the iomux of M4 controller. How to configure a pin in M4 micro-controller?

Thanks for your time.
Regards, Nishanth

Dear @nishanth1829

If you want to be sure that the pin controls are setup correctly, you need to study the i.MX7D reference manual, where all the registers are described in detail.

One other option you can do is:

  1. boot Windows CE on the Colibri
  2. Use our GpioConfig tool to graphically configure all pins as you want.
  3. Use the Reg Access Tool to read out the value of the registers

Regards,
Andy

Hello,
We are using embedded linux v2.8b6 on A7 processor.Is there way to check the register values in linux? Moreover, we are running SPI code in the uboot itself. So how to check if the pin is configured correctly?
Regards

Dear @andy.tx ,
For further clarification, This is the output from ADC when not connected with my evaluation board. And once when I connect the pin with ECSPI3 MISO (C30) on evaluation board, I could see rarely a small spike in the output like this. Is it due to wrong configuration of ECSPI3 MISO, but in my case I am using configuration as provided in the example.

Update:
Further more testing, We found the problem is caused only when we have plugged in the USB OTG to our PC. If we remove the USB OTG, the SPI MISO pin is working fine and We could get the data in our code.
Regards,
Nishanth

Is this happening with Colibri Evaluation Board?
Which ADC IC are you using?
Could you share an connection diagramm?
Thanks and best regards,
Jaski

Hi @jaski.tx ,
Yes it happened with the colibri evaluation board.
The ADC that I am using is ADS8684A.
The connections are just one to one.
Also, this problem does not occur when both the cores are running. The problem occurs only when the M4 alone is run from U-boot.

Regards,
Nishanth

Ok. So if using M4 from U-Boot is needed in your application, then you might check if the MISO Pin is used in U-Boot.

Best regards,
Jaski

Hi,
No just for testing SPI, I checked from U-boot. We will not be using M4 from U-boot.
Regards

Ok, Perfect then the issue is solved.

Best regards,
Jaski