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.

2 MIBSPI (1 master and 1 slave) on RM48

Other Parts Discussed in Thread: HALCOGEN

I'd like to be able to run the MIBSPI1 in master mode while MIBSPI3 is in slave mode, but am having trouble getting it set up. To test the operation, I've externally wired up the CLK from MIBSPI1 to the CLK for MIBSPI3 and the MOSI on MIBSPI1 to the MOSI on MIBSPI3 with no other external hookups. In my main function I have the following:

{
/* USER CODE BEGIN (3) */
    uint16 TX_data[8] = {0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8};
    uint16 RX_data[8] = {0};
    uint16 i=0;

    sciInit();
    mibspiInit();
    rtpInit();

    ti_printf("Done Initializing\r\n");

    mibspiSetData(mibspiREG1, 0, &TX_data[0]);
    mibspiSetData(mibspiREG3, 0, &TX_data[0]);
    mibspiTransfer(mibspiREG1, 0);
    mibspiTransfer(mibspiREG3, 0);
    while(mibspiIsTransferComplete(mibspiREG3, 0) == FALSE);
    mibspiGetData(mibspiREG3, 0, &RX_data[0]);
    ti_printf("Got Data");
    for(i=0;i<8;i++)
    {
        ti_printf("RX_D[%d]: %d\r\n", i, RX_data[i]);
    }
    while(1);



/* USER CODE END */
}

and have messed with the order of setdata/transfer and if I'm waiting for the transfer complete on REG1 or REG3. In my real application, the slave spi (MIBSPI3) will only be receiving data while my master (MIBSPI1) will only be sending data - so I think this is a realistic test. 

Any suggestions on getting it properly set up? In HalCoGen, I've set the baudrate for both to 12.5 MHz, charlen of 16, and TG0 to have a length of 8. 

  • Andrew,

    Which MibSPI1/3 signals have you configured as SPI-functional signals? The MibSPI slave requires at least chip-select 0 in order to work.

    Regards, Sunil

  • Is it possible to use one of the hardware triggers (like GIOA[3]) instead? In the hardware that has already been designed, only the clocks and MOSI signals are brought out from the MIBSPIs, but I do have access to the GIOA ports. 

  • I've modified my halcogen settings to have the CLK, SIMO[0], and SCS[0] functional for both MIBSPI 1 and 3. But I still haven't had any luck with an external loopback on the HDK. Any tips? Do I need to mess with the default chip select or the chip select used with the transfer group? 

  • Andrew,

    One last thing to try before I ask for you to send me your code example. Can you define the return channel (MISO) also as a SPI-functional signal? You don't have to physically connect this signal, just define it as a SPI-functional signal.

    I will check with the experts whether this is a hard requirement for slave mode operation, so that the reference manual can be updated to include it.

    Regards, Sunil

  • I was able to finally get this to mostly work, but still not in the final configuration I need.

    If I have all 4 pins as functional and connect the CS, SIMO, and CLK it will work. However I did need to modify my code to the following

        //    Set up slave
            mibspiSetData(mibspiREG3, 1, &TX_data2[0]);
            mibspiTransfer(mibspiREG3, 1);
            gioSetBit(rtpPORT,17,1);
    
        //  set up master
            mibspiSetData(mibspiREG1, 0, &TX_data[0]);
            mibspiTransfer(mibspiREG1, 0);
    
    
    //  wait til transfer complete
        while (mibspiIsTransferComplete(mibspiREG3, 1) == FALSE);
    //  get data (only REG3 should have valid data)
        mibspiGetData(mibspiREG1, 0, &RX_data[0]);
        mibspiGetData(mibspiREG3, 1, &RX_data2[0]);

    Previously I was using transfer group 0 for both spiREG1 and REG3. I had thought that each spi had it's own data buffer, but that must not be the case. Once I moved to group 1 on the slave, everything worked fine. And if I connected up the MISO signal, I saw the correct data on both. 

    However, in my hardware I need to make work, I don't have access to the CS signal due to missing that in a hardware review.

    I tried in HalCoGen to use set pull-down on the CS0, but that seemed to have no affect. 

    Is it possible to make this work with the trigger source (like GIOA3?) I tried adding some code that loops out and is connected to the input pin A3, but it does not seem to work. Any suggestions on the timing requried?

    Thanks