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.

McBSP- A SPI mode...

Other Parts Discussed in Thread: CONTROLSUITE

Hi all,

 I configured McBSP in SPI clock mode with 8 bit data transfer.

1. When I place a data in DXR1 register, which bit is shifted out first, Bit15(MSB) or Bit0(LSB) of DXR1 register?

 2. Since the SPI data transfer is set at 8-bits, is it required to shift the 8-bit data before placing in DXR1 register?

I would really appreciate If I get answers for the above questions!!!

 

  • Hi Jaiganesh,

    1. Data wil typically be transmitted MSB first, as required by the SPI protocol. It is possible to configure the McBSP module to transmit in the reverse order if necessary though using the XCOMPANDING bits in the XCR2 register.

    2. You can use companding to compress your data to 8 bits. If you don't want to use companding (maybe you are communicating with another device that would not support this) it will depend on how your data you are wanting to transmit is stored. For example, if you want to send the value 0xAA then the value 0xBB, you may have it stored like this: 0x00AA, 0x00BB, or like this: 0xBBAA. If you have it stored the first way, no shifting is required. If you have it stored the second way, you'll need to do a little manipulation.

    I don't know which device you are using, but I'd recommend looking at the following two example projects in controlSUITE or the peripheral header files package: (for a 2833x device for example)

    • controlSUITE/device_support/f2833x/<version>/DSP2833x_examples_ccsv4/mcbsp_spi_loopback
    • controlSUITE/device_support/f2833x/<version>/DSP2833x_examples_ccsv4/mcbsp_loopback

    I hope this helps!

    Regards,

    Katie

  • You may also want to see this other post - it is using 16 bit data, but all data does actually come out of the McBSP 8 bits at a time, if that's really what you need:

    http://e2e.ti.com/support/microcontrollers/tms320c2000_32-bit_real-time_mcus/f/171/p/21118/81553.aspx#81553

  • Hi Katie,

    Thank you for your reply. I am trying to interface SD card with F28335 device using MCBSP SPI closk stop mode. McBSP SPI is master with 8 bit data transfer.

    I need to send six byte command to the SD card

        Uint16 SD_cmd_byte[6] = {0x49,0x00,0x00,0x00,0x00,0x95};

     

        for(byteindex = 0; byteindex < 6; byteindex++)
        
    {
            
    Mcbsp_xmit8(SD_cmd_byte[byteindex]);

            while(McbspaRegs.SPCR2.bit.XRDY == FALSE);
            
            
    while(McbspaRegs.SPCR2.bit.XEMPTY == TRUE);
         }

         void Mcbsp_xmit8(Uint16 data)
         {
           
    McbspaRegs.DXR1.all = data;
         }

    1. Is the above code sequence correct for SPI master 8 bit data transfer?

    2. Is placing data 0x0049 in DXR1 correct for 8 bit data transfer or left shifting of data is required(0x4900). From your answer I understood that left shifting is not necessary. 

    Please correct If I am wrong in any of the steps.

    Thank you

    Jaiganesh

  • Hi Jaiganesh,

    1. The code sequence looks correct for the most part. I personally would get rid of the line: "while(McbspaRegs.SPCR2.bit.XEMPTY == TRUE);".
      1. That line of code will make you wait for an underflow condition before you load DXR1, which is not necessary since DXR1 is not actually the shift register (DXR1 copies data to XSR1, which shifts the data out, leaving us free to reload DXR1). Instead, see section 4.4.2 of the McBSP guide on how to prevent overwrites, since I think that is what you were trying to do with that line of code.
    2. That is correct, you will not need to shift that data, just write 0x0049 to DXR1, for example. Just make sure that you are set up for 8-bit data when you initialize your McBSP module, then it will just send the lower byte.

    I hope this helps!

    Regards,

    Katie

  • Hi Katie,

    This helps a lot!!!

    Thank you

    Jaiganesh