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.

Config SPI_1 2 chip selects

Hi, I'm trying to configure my SPI_1 with 2 chip selects. It work with 1 chip select using cs0, but now I need to use cs0 and cs1.
What functions should I use to configure ?
How send data to cs0 or cs1 ?
How to read from interrupt ?
If someone have a example, pls, let me know.
Thanks in advance.

  • Hi Matheus,

    We are looking into this and will get back to you.

    Lali
  • Hi Lalindra Jayatilleke, thanks.
    I have some extra information:
    -> I can active the chip selects
    -> But, some thing in the config of the McSPITransfer or the Interrupt are wrong. Maybe this is the problem.
    Thanks in advance,

  • Hi Matheus,

    Which platform/ Starterware version are you working with?
    Can you also please post the code that you currently have working with CS0 and CS1.
    Also, did you take a look at the following example starterware\examples\mcspi\flash\ccs\mcspi_app_flash?

    Thanks.

    Lali
  • Hi Lalindra Jayatilleke. I'm sorry, I forgot this information.
    So, I'm using a BBB - BeagleBone Black with AM335X_StarterWare_02_00_01_01.
    Thanks in advance.
  • Hi Matheus,

    Please take a look at the BBB schematic to see how the SPI1 CS0 and CS1 are routed. SPI1_CS0 is on the P9 header.

    Do you have Pin 42 of P9 also muxed for SPI1_CS1?

    From your previous comment, how did you verify that both chip selects were activated?

    Please post the code of your example that you currently have working. Thanks.

    Lali

  • Hi Lalindra.

    I'm using my own board based on BBB, so my cs1 is A15, the config is:

    HWREG(SOC_CONTROL_REGS +CONTROL_CONF_XDMA_EVENT_INTR(0))=0xC;//SPI_1-CS_1

    i would like to sse any example that use two chip selcts.

    My Interrut:

    unsigned int intCode = 0;
        intCode = McSPIIntStatusGet(SOC_SPI_1_REGS);
        while (intCode) {
            /*canal 0 - cs0*/
            if (MCSPI_INT_TX_EMPTY(chNum) == (intCode & MCSPI_INT_TX_EMPTY(chNum))) {
                McSPIIntStatusClear(SOC_SPI_1_REGS, MCSPI_INT_TX_EMPTY(chNum));

                length--;

                McSPITransmitData(SOC_SPI_1_REGS, (unsigned int) (*p_tx++), chNum);

                if (!length) {
                    McSPIIntDisable(SOC_SPI_1_REGS, MCSPI_INT_TX_EMPTY(chNum));

                    McSPIIntStatusClear(SOC_SPI_1_REGS, MCSPI_INT_TX_EMPTY(chNum));
                }
            }

            if (MCSPI_INT_RX_FULL(chNum) == (intCode & MCSPI_INT_RX_FULL(chNum))) {
                McSPIIntStatusClear(SOC_SPI_1_REGS, MCSPI_INT_RX_FULL(chNum));

                *p_rx++ = (unsigned char) McSPIReceiveData(SOC_SPI_1_REGS, chNum);

                if (!(length)) {
                    McSPIIntDisable(SOC_SPI_1_REGS, MCSPI_INT_RX_FULL(chNum));

                    flagInt1 = 0;
                }
            }

    intCode = McSPIIntStatusGet(SOC_SPI_1_REGS);

    }

    To send:

     p_tx = txBuffer;
        p_rx = rxBuffer;
        length=size;
        // SPIEN line is forced to low state.
        McSPICSAssert(SOC_SPI_1_REGS, channel);

        // Enable the Tx/Rx interrupts of McSPI.
        McSPIIntEnable(SOC_SPI_1_REGS, MCSPI_INT_TX_EMPTY(channel) |
                MCSPI_INT_RX_FULL(channel));

        // Enable the McSPI channel for communication.
        McSPIChannelEnable(SOC_SPI_1_REGS, channel);

        // Wait until control returns back from McSPI ISR.
        while (flagInt1);

        flagInt1 = 1;

        // Force SPIEN line to the inactive state.
        McSPICSDeAssert(SOC_SPI_1_REGS, channel);

        // Disable the McSPI channel.
        McSPIChannelDisable(SOC_SPI_1_REGS, channel);

    Maybe there is something wrong in this code.

    Thanks in advance

  • Hi Matheus,

    Unfortunately, we don't have an example for SPI that has both CS's working, and a way to test your code.

    Just to supplement, could you also please take a look at the latest Processor SDK release for AM335x which was just released. This release has a starterware package which has updates (pdk_am335x_1_0_0\packages\ti). You would need the latest CCS 6.1.1 to work with this release.

    Lali