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.

RTOS/AMIC110: SPI usage in Profinet Slave example

Part Number: AMIC110

Tool/software: TI-RTOS

Hi Together,

I want to use the SPI in the PRU-ICSS-Profinet_Slave Example.

What I did till now is to add an Task, which initializes the SPI as following:

void spiFunction(void) {
    static SPI_Handle spiHandle1 = NULL;
    static SPI_Handle spiHandle2 = NULL;
    static SPI_Params spiParams;
    SPI_Transaction spiTransaction;


    TaskP_sleep(20000);    

    //Board_initSPI();
    UART_printf("Start SPI task\n");

    SPI_Params_init(&spiParams);
    spiParams.transferMode = SPI_MODE_BLOCKING;
    spiParams.transferTimeout = SPI_WAIT_FOREVER;
    spiParams.transferCallbackFxn = NULL;
    spiParams.mode = SPI_MASTER;
    spiParams.bitRate = 4000000;
    spiParams.dataSize = 6;
    spiHandle1 = SPI_open(0, &spiParams);
    spiHandle2 = SPI_open(1, &spiParams);

    uint8_t transmitBuffer[1];

    transmitBuffer[0] = 0xFF;

    spiTransaction.count = 1;
    spiTransaction.txBuf = transmitBuffer;
    spiTransaction.rxBuf = NULL;


    while(1) {
        TaskP_sleep(500);
        SPI_transfer(spiHandle1, &spiTransaction);
        SPI_transfer(spiHandle2, &spiTransaction);
        UART_printf("Send spi\n");
    }
}

After this, I checked the pins of the TMDXICE110-BTA board and nothing happens.
So I had a look at the schematic and figured out, that the PIN-HEADS first had to be enabled by setting pin MII2_RXD0 to low. But after one hour of searching I couldn't figure out, how to do this. First I need somehow to define which pin I want to talk to, am I right?

This should be written in an PIN-MUX file. But where to find it? The PROFINET_IRT_Slave_Datasheet says something like that:

"HW signals required to implement PROFINET IRT slave functionality is shown below, this info needs to
be used in conjunction with  http://www.ti.com/tool/PINMUXTOOL"

So do I need to make my own PINMUX-File?

Or how can I talk SPI with this project?

Best Regards

Stefan

  • The RTOS team have been notified. They will respond here.
  • Stefan,

    You don't need make your own PINMUX file for AMIC110 ICE to enable SPI to output its signal to J5 on AMIC110 ICE. The SPI pins except the enabling to PIN-HEADS are configured in the pinmux file in PDK (packages\ti\starterware\board\am335x\am335x_amic11x_pinmux_data.c) already.

    Yes, to enable SPI to output its signals to J5 on AMIC110, you need set BUS_Switch_ENABLE to low. The pinmux/gpio set by default doesn't enable it, and you can manually set BUS_Switch_ENABLE to low. Below is the sample code from EtherCAT - software-dl.ti.com/.../index_FDS.html and you can refer it for SPI usage as well.

    void EnableBusSwitch()
    {
    GPIOModuleEnable(SOC_GPIO_2_REGS);
    GPIODirModeSet(SOC_GPIO_2_REGS, 21, GPIO_DIR_OUTPUT);
    GPIOPinWrite(SOC_GPIO_2_REGS, 21, GPIO_PIN_LOW);
    }

    Regards,
    Garrett
  • Hi Garrett,

    thank you again for your reply!
    I allready managed today to get the SPI work, exact how you described. But now I now where to find the pinmux files.

    But I run into another problem. I want to send 128 bits in one frame. But when i configure the params for more than 32 bits, the SPI_open fails. I'm currently not at my pc, so I don't know the exact error message. When I just change it to less bits, it works.
    Do you have any idea, what could be the problem?

    Regards,
    Stefan
  • Stefan,

    The maximum number of bits is 32 in SPI of AMIC110. From TRM:

    Serial link interface supports:
    – Full duplex / Half duplex
    – Multi-channel master or single channel slave operations
    – Programmable 1-32 bit transmit/receive shift operations.
    – Wide selection of SPI word lengths continuous from 4 to 32 bits

    Regards,
    Garrett
  • Is there any was of having loger frames? If yes, what do I have to do?
  • I think, I got it :)
    If I want to send more than 32bit I just have to set the spiTransaction.count to the desired value. Right?

    Best Regards
    Stefan
  • Stefan,

    The following example code shows spiTransaction.count usage. It actually sends max 32-bits with multiple frames if you define one frame as SPI CS signal remains low. In the case with 128-bit in one frame (CS), you should also need configure SPI0_CS0n A16 pin of AMIC110 from default spi0_cs0 mode (0) to gpio0_5 mode(7) by updating the control module register (95Ch conf_spi0_cs0 Section 9.3.1.50 of TRM, SPRUH73P.pdf), and then toggle the gpio0_5 pin with each 128-bit data transfer when the AMIC110 is configured as SPI master.

    if (testId == SPI_TEST_ID_WORD_LEN)
    {
    /*
    * Word length can be 8/16/32 bits,
    * calculate the SPI word count
    */
    transCount = testLen / (test->param / 8);
    xferBytes = transCount * (test->param / 8);
    }
    else
    {
    /* Default word length is 8-bit */
    transCount = testLen;
    xferBytes = testLen;
    }

    /* Initialize slave SPI transaction structure */
    transaction.count = transCount;

    Regards,
    Garrett