This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[FAQ] SK-AM64B: MCSPI Integration Guide

Part Number: SK-AM64B
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

On Sitara Family of Processors, there are multiple instances of MCSPI present.

Some of the MCSPI instances are available in the MAIN Domain[example: SoC_SPI0] while few of them are from MCU Domain[example: MCU_SPI0].

Few questions from development point of view are as follows:

  1. How to configure MCSPI in MCU PLUS SDK?
  2. How to configure a MCU or MAIN domain MCSPI using SysConfig tool?
  3. How to configure different parameters for MCSPI?
  4. How to configure MCSPI as a Slave?
  5. How to configure chip select lines for MCSPI?
  6. What is the limitation on the dataSize that can be sent or received?

Let's address each of these questions.

  • How to configure MCSPI in MCU PLUS SDK?

    To configure MCSPI we will use the SysConfig tool TI provides. So for a custom application, you will have an example.syscfg file present in the project directory.

    Open the example.syscfg directly if you are in the CCS IDE or from the command line write : gmake syscfg-gui to open the SysConfig tool.

    It should look as follows. 

    Now go ahead and add the MCSPI by clicking on the ADD button inside the MCSPI tab.

    Post adding it should look as follows:

    You have just added a MCSPI instance ready to be used for your application.

  • How to configure a MCU or MAIN domain MCSPI using SysConfig tool?

    Talking about different SoCs, we have different MCSPI instances present and can be found below.

    AM64x:

    5 * MAIN Domain SPI, 2 * MCU Domain SPI

    AM62x, AM62P, AM62A each having:

    3 * MAIN Domain SPI, 2 * MCU Domain SPI

    So for, let's say AM64x, you want to configure Main Domain SPI then you can go ahead and select the option SPI Instance as stated below:

    And for selecting the MCU Domain Instance, go ahead and check the box "Use MCU Domain Peripherals" and then select the instance:

    Now you have successfully learnt to configure MCSPI Instances from different domains.

  • How to configure different parameters for MCSPI?

    Mode(Controller/Peripheral) selection:

    You can choose between three different options for MCSPI. Few of them being Single Controller, Multi Controller and Single Peripheral. You can choose it from the below dropdown option.

    Single Controller: MCSPI instance acts as a Controller/Master and can have only one chip select configured in this mode.

    Multi Controller: MCSPI instance acts as a Controller/Master and can have more than one chip select configured in this mode.

    Single Peripheral: MCSPI instance acts as a Peripheral/Slave in this mode.

    Pin Mode selection:

    You can choose between two modes for pin, namely 3 pin and 4 pin mode.

    3 pin mode: MCSPI Controller is interfaced to the Peripheral using just Clock, MISO and MOSI lines and no CS line is used. NOTE: It is expected in this case that the Peripheral Slave pin is Logic Low.

    4 pin mode: MCSPI Controller is interfaced to the Peripheral using Clock, MISO, MOSI and CS line.

    Transmit/Receive mode selection:

    TX and RX: MCSPI Controller will send and receive data to/from the Peripheral.

    RX Only: MCSPI Controller will only receive the data from the Peripheral.

    TX Only: MCSPI Controller will only send data to the Peripheral.

    MISO/MOSI selection:

    Input Select: Options are D0 and D1 in the dropdown. If you select D0 then D0 will act as MISO else D1 will act as MISO.

    D0 TX Enable: If Input Select is D0, then TX DISABLED, else TX ENABLED.

    D1 TX Enable: If Input Select is D1, then TX DISABLED, else TX ENABLED.

    Operating mode selection:

    You can choose between Interrupt, Polling and DMA mode of operations as shown below in the dropdown.

    Transfer mode selection:

    You can go for one of the below options:

    Blocking transfer: The operation of MCSPI transfer would take place before the function returns. Example: https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/10_00_00_20/exports/docs/api_guide_am64x/EXAMPLES_DRIVERS_MCSPI_LOOPBACK.html

    Callback transfer: The operation of MCSPI transfer would take place after the function returns, hence the term callback. Example: https://github.com/TexasInstruments/mcupsdk-core/blob/next/test/drivers/mcspi/mcspi_controller_peripheral/test_mcspi_controller.c search for test_mcspi_callback API.

    Initial Delay selection:

    Some Peripherals requires few bus clock cycle delays for the first transfer. Referring the datasheet of the Peripheral, if required, you can go ahead and select one of the dropdown options as listed below.

  • How to configure MCSPI as a Slave?

    To configure MCSPI as a Peripheral/Slave you would just need to select Mode of Operation: Single Peripheral in SysConfig window.

    A neat application on AM64x which demonstrates the MCSPI Peripheral/Slave implementation can be found here: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1305146/sk-am64b-r5f-spi-dma-in-mcspi_ms_mode_peripheral/5062348#5062348

    The project file is also provided in the response itself, so you can download it, make the HW connections with jumper cables and run the attached application with ease.

  • How to configure chip select lines for MCSPI?

    Chip Select line selection(Single Controller):

    To interface the Peripheral using a CS line you can go for the below dropdown options and select one among 4 of the available options. NOTE: Every MCSPI instance has 4 CS lines namely, CS0, CS1, CS2 and CS3.

    Frame Format: You can go ahead and change the frame form, by default it is MODE0(CPOL = 0, CPHA = 0), other three options are MODE1(CPOL = 0, CPHA = 1), MODE2(CPOL = 1, CPHA = 0) and MODE3(CPOL = 1, CPHA = 1).

    Clock Frequency: The current frequency in the below screenshot is 1 MHz but can go to a maximum of 50 MHz, please check the list of possible frequencies from the attachment below.

    Chip Select line selection(Multi Controller):

    When multi controller is selected then you can add more than one chip select lines as show below in the attachment:

    Frequency Table:

  • What is the limitation on the dataSize that can be sent or received?

    The dataSize is one of many transaction parameters for MCSPI when you start coding using TI MCU PLUS SDK Drivers.

    The other transaction parameters can be seen below in the snapshot.

    Currently in the SDK drivers, dataSize needs to be atleast 4 bits and not more than 32 bits. This can be seen in the description of the dataSize from the comments in the above snapshot.

    To summarize it from a sample workflow if the following is the MCSPI transaction parameters:

    channel: CS0

    dataSize: x bits (4 >= x <= 32)

    csDisable: True

    count: 4 (random number)

    rxBuf: NULL

    txBuf: [1st value(x bits), 2nd value(x bits), 3rd value(x bits), 4th value(x bits)]

     

    NOTE: When you initiate transfer, MCSPI Controller will send 4 values each of x bits to the Peripheral/Slave.