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/TDA2P-ACD: McSPI3 MULTI_CHANNEL Mode Not Working on Custom TDA2P Board

Part Number: TDA2P-ACD
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hello All,

We have configured McSPI3 as shown below in our "platform_tda2xx_pad_config.c" file in PSDK 03.03,

    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE + CTRL_CORE_PAD_MCASP1_AXR8,                            //SCLK
                0xc0003);
    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE + CTRL_CORE_PAD_MCASP1_AXR9,                           //MOSI
                0xc0003);
    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE + CTRL_CORE_PAD_MCASP1_AXR10,                         //MISO
                0xc0003);
    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE + CTRL_CORE_PAD_MCASP1_AXR11,                        //CS0-Acceleromter
                0x60003);
     HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE + CTRL_CORE_PAD_MCASP1_AXR12,                       //CS1-Gyro
                0x60003);
    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE + CTRL_CORE_PAD_MCASP1_AXR7,                          //Accel INT
                (0x60000U | CTRL_CORE_PAD_MCASP1_AXR7_MCASP1_AXR7_MUXMODE_GPIO5_9_14));
    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE + CTRL_CORE_PAD_MCASP1_AXR3,                          //Gyro INT
                (0x60000U | CTRL_CORE_PAD_MCASP1_AXR3_MCASP1_AXR3_MUXMODE_GPIO5_5_14));   

And we have also read the control pad registers on CCS memory browsers and we got the same values as was set from the above code.

We have Accelerometer Gyroscope combo chip connected on our custom TDA2P board over McSPI3. Both Accelero and gyro have different chip select pins. So we have used MCSPI in Multichannel mode by setting :

==> "mcspiPrms.spiHWCfgData.singleOrMultiChEnable = MCSPI_MULTI_CHANNEL". &

==> channel 0 & 1 for accel & gyro respectively . For example,

mcspiPrms.spiHWCfgData.configChfmt[0] -------- For Accelero

mcspiPrms.spiHWCfgData.configChfmt[1] -------- For Gyro

We debugged our code and found out that, when we execute following,

"mcspiHandle_gyro = GIO_create("/mcspi2", GIO_INOUT, &ioParams, &eb);"

we get below error,

"

*ERROR* Line: 276, File: src/bsp_mcspi.c - SPIEN hold (FORCE bit) is invalid in MULTI channel mode,cannot open the channel
ti.sysbios.io.GIO: line 253: ti.sysbios.io.GIO: line 253: E_createFailed: mdCreateChan returned error -1

"

Can anyone suggest how can we make MULTI_CHANNEL mode work.

Thanks,

Abhay

  • Hi Abhay,

    In case of multi channel mode the SPIEN cant be kept active between successive SPI words.

    You can refer the section "Force SPIEN[x] Mode" in the TRM.

    In the driver you can set the chanParams.spiChipSelectHold  to FALSE which is passed to GIO_create.

    Regards,
    prasad

  • Hi Prasad,

    With the changes you suggested we were able to fix the MULTICHANNEL issue. But now we are facing a different issue.
    As soon as we enable the GPIO interrupt for our accelero/gyroscope by executing the function " GPIOPinIntEnable(gpio_base_address, GPIO_INT_LINE_2, gpio_pin_gyro)", the code goes into run mode and continuously generate the interrupts(We are putting a breakpoint in ISR).
    The code after the "GPIOPinIntEnable" is not getting executed. We are not getting any runtime error though. Can you suggest what could be the issue.

    Thanks,
    Abhay
  • Hi Prasad,

    Please let me know if you require more details regarding this.

    Regards,
    Abhay
  • Hi Prasad,

    Do you have any update for us.
    One thing I observed is we are getting below error if keep "chan1Params.fifoEnable = (UInt32) TRUE",
    "
    *ERROR* Line: 276, File: src/bsp_mcspi.c - FIFO is already being used, cannot open the channel
    ti.sysbios.io.GIO: line 253: ti.sysbios.io.GIO: line 253: E_createFailed: mdCreateChan returned error -10
    "

    The above error comes when we execute "GIO_create" for the second time with "chanParams.chanNum = 1".
    Please suggest how to solve this issue.

    Thanks,
    Abhay
  • Hi,

    We have one more doubt. Do we need to set "mcspiPrms.opMode = MCSPI_OPMODE_INTERRUPT"when we are using "MCSPI_MULTI_CHANNEL". Currently we have set "mcspiPrms.opMode = MCSPI_OPMODE_POLLED"

    Regards,
    Abhay
  • Hi Abhay,

    1. MCSPI polled vs interrupt mode should not matter.
    2. There is only one HW FIFO so two channels can't use it at the same time. You should set fifoenable to FALSE for one of them.

    Regards,
    Rishabh
  • Hi Abhay,

    Are you clearing the interrupt in ISR? What is the frequency at which interrupt is being generated?

    Regards,
    Rishabh
  • Hi Rishabh,

    Yes I am clearing the interrupt in ISR using "GPIOPinIntClear(GPIO5_BASE_ADDR, GPIO_INT_LINE_2, gpioPinNum)" API.
    Currently the frequency of interrupt for Accelero is set to 1ms (default but configurable) & Gyro is set to 4ms (default but configurable).

    There is no problem when we are running in MCSPI_SINGLE_CHANNEL with only Acceleromenter ISR. But when we run the code in MCSPI_MULTI_CHANNEL we are facing the above issues.

    Regards,
    Abhay
  • Hi Rishabh,

    Do you have any suggestions for us. We are still facing issues in generating interrupts in MCSPI_MULTI_CHANNEL mode.

    Regards,
    Abhay
  • Hi Abhay,

    Can you check if there is any problem when you are running in MCSPI_SINGLE_CHANNEL with only Gyro.

    Regards,
    Rishabh
  • Hi Rishabh,

    Do you mean with MCSPI_SINGLE_CHANNEL and chanNum = 1 and with single GIO_Create as below,
    "
    chanParams.chanNum = 1;

    mcspiPrms.opMode = MCSPI_OPMODE_POLLED;
    mcspiPrms.instNum = SPI_INSTANCE;
    mcspiPrms.hwiNumber = 7;
    mcspiPrms.enableCache = (UInt32) TRUE;
    mcspiPrms.edma3EventQueue = 0;
    mcspiPrms.enableErrIntr = (UInt32) FALSE;
    mcspiPrms.spiHWCfgData.masterOrSlave = MCSPI_COMMMODE_MASTER;
    /*Configuring for multi channel - different channels for Accelerometer and Gyro*/
    mcspiPrms.spiHWCfgData.singleOrMultiChEnable = MCSPI_SINGLE_CHANNEL;
    mcspiPrms.spiHWCfgData.pinOpModes = MCSPI_PINOPMODE_4PIN;
    mcspiPrms.spiHWCfgData.fifoRxTrigLvl = 32;
    mcspiPrms.spiHWCfgData.fifoTxTrigLvl = 32;

    /*Configuration for channel for ACCELEROMETER*/
    mcspiPrms.spiHWCfgData.configChfmt[0].charLength = MCSPI_LEN_8BIT;
    mcspiPrms.spiHWCfgData.configChfmt[0].multiWordAccessEnable =
    (UInt32) FALSE;
    /*Chip Select is Configured as Active Low*/
    mcspiPrms.spiHWCfgData.configChfmt[0].spiChipSelectEnablePol =
    (UInt32) FALSE;

    /*SPICLK active high and sampling occurs on the rising edge*/
    mcspiPrms.spiHWCfgData.configChfmt[0].clockMode = MCSPI_MODE0;
    mcspiPrms.spiHWCfgData.configChfmt[0].clockRatioExtension = 0;
    mcspiPrms.spiHWCfgData.configChfmt[0].spiWordInitDelay = MCSPI_NO_DELAY;

    mcspiPrms.spiHWCfgData.configChfmt[0].trasmitReceiveMode = MCSPI_BOTH_RXTX;
    mcspiPrms.spiHWCfgData.configChfmt[0].granularityEnable = (UInt32) TRUE;

    mcspiPrms.spiHWCfgData.configChfmt[0].busFreq = 1000000;
    mcspiPrms.spiHWCfgData.configChfmt[0].spienHighPolarity = (UInt32) FALSE;
    mcspiPrms.spiHWCfgData.configChfmt[0].slaveModeChipSelect = MCSPI_SPIEN_0;
    mcspiPrms.spiHWCfgData.configChfmt[0].spiDat0Dir = MCSPI_IN;
    mcspiPrms.spiHWCfgData.configChfmt[0].spiDat1Dir = MCSPI_OUT;

    "

    Regards,
    Abhay
  • Hi Abhay,

    My understanding is that you have gyro & accelero in your system and one of them is working in single instance.
    The idea is to make sure that other is also working when used as a single instance before putting both of them together.
    You should set the similar params what you want to use finally with minimum differences like mode, etc.

    Regards,
    Rishabh
  • Hi Rishabh,

    Yes accelero is working in Single channel mode with chanNum = 0.
    We tried gyro in single channel mode with chanNum = 1 and read the gyro chip ID, but we are not getting any data.

    Regards,
    Abhay
  • Hi Abhay,

    Have you set FIFO enable to yes while you are trying this?
    You should review the differences between accelero params and gyro params.

    Regards,
    Rishabh
  • Hi Rishabh,

    Yes we did try with ,

    chanParams.fifoEnable = (UInt32) TRUE;
    chanParams.spiChipSelectHold = (UInt32) TRUE;
    chanParams.chanNum = 1;

    But not able to read the correct chip ID in case of gyro.

    Regards,
    Abhay
  • Hi Abhay,

    Have you checked if you have set the pin mux for CS1?

    Regards,
    Rishabh
  • Hi Rishabh,

    Yes we have set the following Pinmux settings,

       HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE + CTRL_CORE_PAD_MCASP1_AXR8, 0xc0003);   //SCLK

       HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE + CTRL_CORE_PAD_MCASP1_AXR9, 0xc0003);   //MOSI

       HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE + CTRL_CORE_PAD_MCASP1_AXR10, 0xc0003);  //MISO

       HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE + CTRL_CORE_PAD_MCASP1_AXR11, 0x60003);   //CS0-Acceleromter

    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE + CTRL_CORE_PAD_MCASP1_AXR12, 0x60003);   //CS1-Gyro

    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE + CTRL_CORE_PAD_MCASP1_AXR7, 

         (0x60000U | CTRL_CORE_PAD_MCASP1_AXR7_MCASP1_AXR7_MUXMODE_GPIO5_9_14));   //Accel INT

    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE + CTRL_CORE_PAD_MCASP1_AXR3,

          (0x60000U | CTRL_CORE_PAD_MCASP1_AXR3_MCASP1_AXR3_MUXMODE_GPIO5_5_14));  //Gyro INT

    Regards,

    Abhay

  • Hi Abhay,

    I am assuming you have taken care of enabling pull type as per your board schematics.
    Next step should be to probe lines why the communication is not happening.
  • Hi Rishabh,

    We have already probed the CS, MISO, MOSI & SCK line while writing to and reading from Gyro registers. We are able to see proper data being written but we are not able to read correct data which is written.

    Regards,
    Abhay
  • Hi Rishabh,

    One doubt,If the CS is already pull up from hardware,also in Software we have given PULL UP to that pad.
    Will that have any effect?

    Thanks,
    Abhay
  • Hi Rishabh,

    Do you any suggestions for us on how to make MULTICHANNEL MCSPI work, as we are still not able to resolve this issue.
    One more thing I want to ask, is MCSPI tested by TI with MCSPI_MULTI_CHANNEL mode. If yes, please share the example code if possible so that we can try out same at our end.

    Thanks,
    Abhay
  • Hi Abhay,

    Sorry I kind of lost track of this thread.
    I had suggested you to try making the single channel mode work for gyro.
    Did that work for you?

    Regards,
    Rishabh
  • Hi Rishabh,

    Yes I have tested Gyro in single channel mode with interrupts. It is working fine.
    ISR is invoked and data is also coming as expected.

    Regards,
    Abhay
  • Hi Rishabh,

    Can you suggest how to proceed further with Accelero & Gyro together in MCSPI_MULTI_CHANNEL mode.

    Thanks,
    Abhay
  • Hi Rishabh,

    Also, if possible please share any MCSPI example code running in MCSPI_MULTI_CHANNEL mode.

    Regards,
    Abhay
  • Hi Rishabh,

    Please suggest the correct MCSPI settings to work in MCSPI_MULTI_CHANNEL mode.

    Regards,
    Abhay
  • Hi Abhay,

    Shall we have a call at 3 pm today?

    Regards,
    Rishabh
  • Hi Rishabh,

    Sure we can have call at 3PM.
    Please share the call/webex details.

    Regards,
    Abhay
  • Hi,

    Kindly share your email id so that I can send the invite.

    Regards,
    Rishabh
  • Hi Rishabh,

    I have sent my email address to you over message.

    Regards,
    Abhay
  • Hi Abhay,

    Please try the steps discussed in the call and reply to this post in case you face issues.
    Thanks.

    Regards,
    Rishabh
  • Sure Rishabh,

    Thanks,
    Abhay
  • Hi Abhay,

    Is there an update on this issue?

    Regards,
    Rishabh

  • Hi Rishabh,

    I have tried with the following settings suggested by Prasad. I am able to read the correct Chip ID for Accelero and gyro but I am not able to generate the ISR. I am currently checking what the issue is. I will update you accordingly.

    "
    mcspiPrms.spiHWCfgData.singleOrMultiChEnable = MCSPI_MULTI_CHANNEL;
    mcspiPrms.spiHWCfgData.configChfmt[0].charLength = MCSPI_LEN_16BIT;
    "

    Thanks,
    Abhay
  • Hi Rishabh, Hi Prasad,

    With some minor changes in ISR, now I am able to generate interrupts for both accelero and gyro in MCSPI_MULTI_CHANNEL mode.
    Following settings as suggested by Prasad worked for me,

    "
    /*Interrupt OPMODE considered for SPI*/
    mcspiPrms.opMode = MCSPI_OPMODE_POLLED;
    mcspiPrms.instNum = 2;
    mcspiPrms.hwiNumber = 7;
    mcspiPrms.enableCache = (UInt32) TRUE;
    mcspiPrms.edma3EventQueue = 0;
    mcspiPrms.enableErrIntr = (UInt32) FALSE;
    mcspiPrms.prcmPwrmEnable = TRUE;
    mcspiPrms.spiHWCfgData.masterOrSlave = MCSPI_COMMMODE_MASTER;
    /*Configuring for multi channel - different channels for Accelerometer and Gyro*/
    mcspiPrms.spiHWCfgData.singleOrMultiChEnable = MCSPI_MULTI_CHANNEL;
    mcspiPrms.spiHWCfgData.pinOpModes = MCSPI_PINOPMODE_4PIN;
    mcspiPrms.spiHWCfgData.fifoRxTrigLvl = 32;
    mcspiPrms.spiHWCfgData.fifoTxTrigLvl = 32;

    #ifdef ACCELERO_EN
    /*Configuration for channel for ACCELEROMETER*/
    mcspiPrms.spiHWCfgData.configChfmt[0].charLength = MCSPI_LEN_16BIT;
    mcspiPrms.spiHWCfgData.configChfmt[0].multiWordAccessEnable =
    (UInt32) FALSE;
    /*Chip Select is Configured as Active Low*/
    mcspiPrms.spiHWCfgData.configChfmt[0].spiChipSelectEnablePol =
    (UInt32) FALSE;
    /*SPICLK active high and sampling occurs on the rising edge*/
    mcspiPrms.spiHWCfgData.configChfmt[0].clockMode = MCSPI_MODE0;
    mcspiPrms.spiHWCfgData.configChfmt[0].clockRatioExtension = 0;
    mcspiPrms.spiHWCfgData.configChfmt[0].spiWordInitDelay = MCSPI_NO_DELAY;
    mcspiPrms.spiHWCfgData.configChfmt[0].trasmitReceiveMode = MCSPI_BOTH_RXTX;
    mcspiPrms.spiHWCfgData.configChfmt[0].granularityEnable = (UInt32) TRUE;
    mcspiPrms.spiHWCfgData.configChfmt[0].busFreq = 1000000;
    mcspiPrms.spiHWCfgData.configChfmt[0].spienHighPolarity = (UInt32) FALSE;
    mcspiPrms.spiHWCfgData.configChfmt[0].slaveModeChipSelect = MCSPI_SPIEN_0;
    mcspiPrms.spiHWCfgData.configChfmt[0].spiDat0Dir = MCSPI_IN;
    mcspiPrms.spiHWCfgData.configChfmt[0].spiDat1Dir = MCSPI_OUT;
    #endif

    /*Configuration for channel for GYRO*/
    #ifdef GYRO_EN
    mcspiPrms.spiHWCfgData.configChfmt[1].charLength = MCSPI_LEN_16BIT;
    mcspiPrms.spiHWCfgData.configChfmt[1].multiWordAccessEnable =
    (UInt32) FALSE;
    /*Chip Select is Configured as Active Low*/
    mcspiPrms.spiHWCfgData.configChfmt[1].spiChipSelectEnablePol =
    (UInt32) FALSE;
    /*SPICLK active high and sampling occurs on the rising edge*/
    mcspiPrms.spiHWCfgData.configChfmt[1].clockMode = MCSPI_MODE0;
    mcspiPrms.spiHWCfgData.configChfmt[1].clockRatioExtension = 0;
    mcspiPrms.spiHWCfgData.configChfmt[1].spiWordInitDelay = MCSPI_NO_DELAY;

    mcspiPrms.spiHWCfgData.configChfmt[1].trasmitReceiveMode = MCSPI_BOTH_RXTX;
    mcspiPrms.spiHWCfgData.configChfmt[1].granularityEnable = (UInt32) TRUE;

    mcspiPrms.spiHWCfgData.configChfmt[1].busFreq = 1000000;
    mcspiPrms.spiHWCfgData.configChfmt[1].spienHighPolarity = (UInt32) FALSE;
    mcspiPrms.spiHWCfgData.configChfmt[1].slaveModeChipSelect = MCSPI_SPIEN_0;
    mcspiPrms.spiHWCfgData.configChfmt[1].spiDat0Dir = MCSPI_IN;
    mcspiPrms.spiHWCfgData.configChfmt[1].spiDat1Dir = MCSPI_OUT;
    #endif

    And below settings for GIO_create,

    chanParams[0].chipSelTimeControl = MCSPI_CLK_CYCLE0;
    chanParams[0].fifoEnable = (UInt32) TRUE;
    chanParams[0].spiChipSelectHold = (UInt32) FALSE;

    /*Channel 0 is used for Accelerometer*/
    chanParams[0].chanNum = 0;

    ioParams.chanParams = (Ptr) &chanParams[0];
    ioParams.model = GIO_Model_ISSUERECLAIM;
    ioParams.numPackets = NUM_BUFS + 1;

    /*creating accel handle using GIO module*/
    mcspiHandle_accel = GIO_create("/mcspi2", GIO_INOUT, &ioParams, &eb);
    if (mcspiHandle_accel == NULL)
    {
    Vps_printf("\r\nCreate Accelero SPI Device FAILED.\r\n");
    status = STATUS_FAIL;
    }
    else
    {
    chanParams[1].chipSelTimeControl = MCSPI_CLK_CYCLE0;
    chanParams[1].fifoEnable = (UInt32) FALSE;
    chanParams[1].spiChipSelectHold = (UInt32) FALSE;

    /*Channel 1 is used for Gyroscope*/
    chanParams[1].chanNum = 1;
    ioParams.chanParams = (Ptr) &chanParams[1];
    ioParams.model = GIO_Model_ISSUERECLAIM;
    ioParams.numPackets = NUM_BUFS + 1;

    mcspiHandle_gyro = GIO_create("/mcspi2", GIO_INOUT, &ioParams, &eb);
    if (mcspiHandle_gyro == NULL)
    {
    Vps_printf("\r\nCreate Gyro SPI Device FAILED.\r\n");
    status = STATUS_FAIL;
    }
    }
    "

    Thank you very much for your support in solving this problem.

    Regards,
    Abhay
  • Hi Abhay,

    Glad to know that this issue is resolved.
    I will close this thread.

    Regards,
    Rishabh