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.

PROCESSOR-SDK-AM64X: MCSPI two channel one handler

Part Number: PROCESSOR-SDK-AM64X
Other Parts Discussed in Thread: TMDS64EVM

Tool/software:

Hi,

I am running the dev board TMDS64EVM.

I only need one spi controller, however, I have two channel.  Each of channel is correspending to a separate CS.


after I use   "MCSPI_transfer"  to the first channel, I tried to transfer the data to the second channel. it is not working on second transfer. 

I have to config  it to  MCSPI_CH_MODE_SINGLE mode, since I need force CS enable.

Need to mention, if I make transfer standalone, either for channel 1 and channel 0, all works fine. 

However, If I tried to consecutively transfer to 0 then transfer to 1, it failed. 

how to solve, did I forgot to close,  but I am sure, I dis select  CSL_MCSPI_CH0CTRL_EN_MASK in the end. to disable the current channel. 


what is the wrong, why it can't consecuritvely transfer?

Thanks  

code for configruation

<code>

uint32_t gMcspiNumCh[2] =
{
    CONFIG_MCSPI0_NUM_CH,
};

/* MCSPI atrributes */
static MCSPI_Attrs gMcspiAttrs[CONFIG_MCSPI_NUM_INSTANCES] =
{
    {
        .baseAddr           = CSL_MCSPI0_CFG_BASE,
        .inputClkFreq       = 50000000U,
        .intrNum            = 204,
        .operMode           = MCSPI_OPER_MODE_POLLED,
        .intrPriority       = 4U,
        .chMode             = MCSPI_CH_MODE_SINGLE,
        .pinMode            = MCSPI_PINMODE_4PIN,
        .initDelay          = MCSPI_INITDLY_0,
        .multiWordAccess    = FALSE,

    },
    {
        .baseAddr           = CSL_MCSPI1_CFG_BASE,
        .inputClkFreq       = 50000000U,
        .intrNum            = 205,
        .operMode           = MCSPI_OPER_MODE_POLLED,
        .intrPriority       = 4U,
        .chMode             = MCSPI_CH_MODE_SINGLE,
        .pinMode            = MCSPI_PINMODE_4PIN,
        .initDelay          = MCSPI_INITDLY_0,
        .multiWordAccess    = FALSE,

    },
};
/* MCSPI objects - initialized by the driver */
static MCSPI_Object gMcspiObjects[CONFIG_MCSPI_NUM_INSTANCES];
/* MCSPI driver configuration */
MCSPI_Config gMcspiConfig[CONFIG_MCSPI_NUM_INSTANCES] =
{
    {
        &gMcspiAttrs[CONFIG_MCSPI0],
        &gMcspiObjects[CONFIG_MCSPI0],
    },

}

</code>

code for transferation
<code>

   
    MCSPI_Transaction_init(&spiTransaction);
   
    spiTransaction.channel  = 0;
    spiTransaction.dataSize = (uint32_t)8;
    spiTransaction.csDisable = TRUE;
   
    /* number of frames in the transfer */
    spiTransaction.count    = (uint32_t)1;
    spiTransaction.txBuf    = (void *)&spibuf[0];
    spiTransaction.rxBuf    = NULL;
    spiTransaction.args     = NULL;

    int status = MCSPI_transfer(g_spi_handles[input], &spiTransaction);
    
    uint32_t chctrl_current = MCSPI_readChCtrlReg(CSL_MCSPI0_CFG_BASE, 0);
     chctrl_current &=~CSL_MCSPI_CH0CTRL_EN_MASK;   //disable channel. 
    MCSPI_writeChCtrlReg(CSL_MCSPI0_CFG_BASE, 0, chctrl_current);
    /*second transfer will not work */
    MCSPI_Transaction_init(&spiTransaction);
   
    spiTransaction.channel  = 1;
    spiTransaction.dataSize = (uint32_t)8;
    spiTransaction.csDisable = TRUE;
   
    /* number of frames in the transfer */
    spiTransaction.count    = (uint32_t)1;
    spiTransaction.txBuf    = (void *)&spibuf[0];
    spiTransaction.rxBuf    = NULL;
    spiTransaction.args     = NULL;
    chctrl_current = MCSPI_readChCtrlReg(CSL_MCSPI0_CFG_BASE, 1);
    chctrl_current &=~CSL_MCSPI_CH0CTRL_EN_MASK;   //enable channel. 
    MCSPI_writeChCtrlReg(CSL_MCSPI0_CFG_BASE, 1chctrl_current);  //enablethe second channel
    //below  MCSPI_transfer  NOT WORKING 
    int status = MCSPI_transfer(g_spi_handles[input], &spiTransaction);

</code>

  • I solve the problem. Thanks. 

    When in single channel mode, it means you can only spi-transfer one channle at a time. You will need to close the channel. and reopen, in order to transfer another channel.