AM6548: SPI Drivers in C for AM6548

Part Number: AM6548


Hi,

I am trying to develop a C kernel program that utilizes the SPI of the AM6548. I am configuring the SPI module (McSPI1, ch0) as per the datasheet. When I enter data into the Tx register, data is NOT shifted out. Is this due to a lack of a clock? If so, how can I go about debugging this? If not, what are some reasons why this is?

Thank you in advance. 

  • Hello,

    I believe you are working with the Linux SDK or the Processor SDK Linux. Please clarify this.

    Could you please check the following points at your end?

    1. You can run the MCSPI by either of the two methods:
      1. You either perform a loopback
      2. Or you configure the MCSPI as a Controller(and some external Peripheral) or as a Peripheral(and some external Controller).
    2. Please make sure the lines are configured in the DTS correctly, for example the D0, D1, CLK and CS lines. Make sure the pinmux is defined correctly.
    3. Clock should be mandatory as the TX and RX operations are purely data shift operations, and data shifting happen only on Clock Edges(falling or rising).

    Bonus: If you have access to logic analyzer or an oscilloscope or any tool with the help of which you can analyze the signals, check the clock by probing it, it should be helpful, you could also check the other lines as well if needed.

    Regards,

    Vaibhav

  • Hi Vaibhav,

    Thanks for the response.

    I am not using the Linux SDK. I am using VxWorks. However, for all intents and purposes, I do not think it matters, because I am writing my drivers as if they are bare-metal. I am directly modifying the registers of the SPI controller for configuration and transmission.

    1a. I am trying to perform a loopback just to verify the SPI operation in my driver code.

    1b. Configuring the MCSPI as the controller with some external peripheral is the next goal.

    2. This is my pinmux configuration:

       

    main_spi1_pins_default: main_spi1_pins_default {
    		pinctrl-single,pins = <
    			AM65X_IOPAD(0x01d8, PIN_INPUT, 0) /* (AH12) SPI1_CLK */
    			AM65X_IOPAD(0x01dc, PIN_INPUT, 0) /* (AE12) SPI1_D0 */
    			AM65X_IOPAD(0x01e0, PIN_INPUT, 0) /* (AF12) SPI1_D1 */
    			AM65X_IOPAD(0x01d0, PIN_OUTPUT, 0) /* (AD12) SPI1_CS0 */
    			AM65X_IOPAD(0x01d4, PIN_OUTPUT, 0) /* (AG12) SPI1_CS1 */
    			AM65X_IOPAD(0x0180, PIN_OUTPUT, 1) /* (AD18) PRG1_MDIO0_MDIO.SPI1_CS2 */
    			AM65X_IOPAD(0x0184, PIN_OUTPUT, 1) /* (AH18) PRG1_MDIO0_MDC.SPI1_CS3 */
    		>;
    	};

        I am trying to use SPI1 in my code. I used TI Pin Mux tool to get this configuration. I did notice that the D0 and CLK pins are dedicated as inputs, but the SPIDEV driver in Linux accepts this configuration.

    3. Yes, clocking should be mandatory. I think this might be the likely cause of why my configuration is not working. I followed the configuration according to the TRM of the AM6548. I am able to write data to the Tx register, but data does not shift out. 

    Bonus: I have the ability to probe signals, but nothing is shifting out, so there is no information to gather by probing yet.

  • I am trying to perform a loopback just to verify the SPI operation in my driver code.

    Could you please tell me if you are trying to perform an Internal Loopback or an external Loopback?

    External would mean, you shorting D0 and D1 via HW Jumper cables.

    Let me know so that I can suggest changes to pinmux accordingly or provide further debug steps.

  • I am performing an external loopback between D0 and D1 via a HW jumper cable.

  • Hello,

    Assuming D0 is MOSI, please configure D1 is Input and the rest as Output. Also remove the other CS which is not in use like cs1, cs2 assuming you are ysing cs0.

    Give this configuration a try and let me know the results.

  • Hi Vaibhav,

    I tried this and it did not solve anything. Do you have any other suggestions?

  • Hello,

    Given D0 sends data to D1, the above configuration should have worked for External Loopback. Given that this is not working, I would route your thread to a Hardware expert to comment/check further on this.

    Please let us know if the EVM is TI EVM or a DUT(custom board)?

    Regards,

    Vaibhav

  • Hi All, 

    I will need the schematics (PDF, searchable) related to the SPI interface - processor and attached device to review.

    Regards,

    Sreenivasa