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.

Sample code for McBSP in SPI mode does not work when switched from McBSP0 to McBSP1

Hi,

The following is a summary of the environment I am using:

Hardware - DM6437 EVM from spectrum digital

CCS - 3.3

DVSDK - 1.01.00.15

PSP - 1.10.03

I am trying to reuse the sample application from TI which transfers a few buffers over McBSP0 in SPI master mode and it receives it back on the receive pins of McBSP0 port itself. I am trying to get the same transfer happen on the McBSP1 port instead. The attached file has the sample McBSP0 code. Also, I am externally connecting the transmit pins of the McBSP0 to receive pins of McMSP0. The way the code is written, even if these external connections are not made, the transmission will still happen and the comparing of the received buffer with the transmitted buffer will fail.

The simple change that I have done is to change the following line:

    mcbspHandle =  GIO_create("/McBSP0",IOM_OUTPUT,NULL,&chanparams,&gioAttrs);

to

    mcbspHandle =  GIO_create("/McBSP1",IOM_OUTPUT,NULL,&chanparams,&gioAttrs);

 

At this point, I hoped the code will work if I now moved the external connections to connect the transmit pins of McBSP1 to receive pins of McBSP1. However, that did not happen! The GIO_submit will block forever (as I am trying to transmit in synchronous mode). In fact, if I change the timeout to say 2 seconds, we can clearly see that transmission is not happening, it times out. The more weird behavior is, suppose I revert the external connections to McBSP0 and do like below:

    mcbspHandle =  GIO_create("/McBSP1",IOM_OUTPUT,NULL,&chanparams,&gioAttrs);

    mcbspHandle2 =  GIO_create("/McBSP0",IOM_OUTPUT,NULL,&chanparams,&gioAttrs);

and I continue with GIO_submit on mcbspHandle (which refers to McBSP1), I see that the transmission and reception happens on McBSP0!! Can someone please help me in resolving this and getting McBSP1 to work as I expect it to?

 

Thanks in advance.

 

Regards,

Sreenath K R

  • Hi Sreenath,

    Loooking into your issue, I can comment few things..

    The sample application provided by the PSP package is configured to McBSP0. To configure it to operate on McBSP1,

    You should make the following changes:

    1. Create a McBSP1 device in the .tci file with correct device id (you hav done it in .tcf file and its fine).

    2. Make sure you pass the correct intrNum. (You have done it, but make sure the intrNum is correct).

    3. By doing so, your sample application should work for McBSP1 directly since driver supports both the instance of McBSP. (Create only one instance of the device to make debugging easier, since code provided by you has both instances operating).

    So, in your case just create McBSP1 instance and proceed with the application.

    Sreenath Ramanna said:
        mcbspHandle =  GIO_create("/McBSP1",IOM_OUTPUT,NULL,&chanparams,&gioAttrs);
        mcbspHandle2 =  GIO_create("/McBSP0",IOM_OUTPUT,NULL,&chanparams,&gioAttrs);
    and I continue with GIO_submit on mcbspHandle (which refers to McBSP1), I see that the transmission and reception happens on McBSP0!!

    This seems to be quite tricky.. In this case, you have to debug and look into it and firstly confirm that the correct instance number is passed throughout, and check that the corresponding base address of the McBSP instance is assigned. If the base address is proper, then there is no way that the data transaction will occur on  McBSP0 by using the McBSP1 handle.

    When the device instance is created for perticular instance, the code flow would be like UDEV_create() -> mcbsp_mdbindDev() -> PSP_mcbspCreate() -> LLC_mcbspOpen(). In here, the base address will be assigned.

    If you are using CCS, then open memory window for register set of both the instance, and check which instance's register is getting modified. 

    Could you please verify the hardware connection also? (I know it will be fine, but i just want to make sure) 

    Thanks and Regards,

    Raghavendra M

     

  •  

    Hi Raghavendra,

     

    Thanks for your response. The simple change that you suggest - making sure right interrupt number is used, does not help me. I still am not able to make McBSP1 work. 

     

    After logging the issue on the e2e forum I was also able to trace through the driver code and see that right indexes are being passed (0 for McBSP0 and 1 for McBSP1). The following are the handles / addresses I see while tracing the device driver code:

     

    McBSP0

    ------

    Port Handle: 0x810352f8

    io Handle: 0x81031c5c

    EDMA channel Tx: 2U

    EDMA channel Tx: 3U

     

    McBSP0

    ------

    Port Handle: 0x8103532C

    io Handle: 0x81032698

    EDMA channel Tx: 4U

    EDMA channel Tx: 5U

     

    In the case when I create both the devices I see that right handles are being accessed too.

     

    Please look at the attached image for register dumps. The base addresses that are being linked to McBSP are from soc.h which defines them as below:

    /** @brief Base address of MCBSP memory mapped registers */

    #define CSL_MCBSP_0_REGS                (0x01D00000u)

    #define CSL_MCBSP_1_REGS                (0x01D00800u)

     

    I am curious, were you able to reproduce the defect? If you are able to make transmission happen on McBSP1 by modifying the sample code, it would mean we have no issue at all. Then it would mean - either I am doing some silly mistake or my software packages are not appropriate or something like that. Let us ignore the anamolous behavior of McBSP1 handle sending data out on McBSP0. The anomoly might have been a case when the h/w was not properly loaded or some such thing. Let us focus on just getting the sample code to work with McBSP1 instead of McBSP0. 

    Thanks again, for helping out in this issue.
    Regards,
    Sreenath
    McBSP0 registers:
    McBSP1 registers:

     

  • Hi Sreenath,

    The attachment you shared, looks like the application(psp_bios_mcbsp_sample.c) is configured to opmode INTERRUPT mode of operation. Just to make sure if another instance(McBSP1)you are creating really works. So, Can you change it to opmode DMAINTERRUPT and check?.

    Please let me know the result.

    Thanks & regards,

    Raghavendra