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 as a SPI in Tms320f2812 (Problem in configuring 8 bit)

Other Parts Discussed in Thread: TMS320F2812

Hi,

I'm using Mcbsp as a SPI in Tms320f2812. Problem is my SPI slave is 8bit, there is a option to configure 8,12 16 or 32 bit for  TX and RX data length . it is communicating when i configured as 16bit but it is not communicating for 8 bit configuration for TX and RX data length. Please tell me whats the problem in that & hw to communicate for 8bit data length.

any suggestions.

-Gavi Prakash 

  • Gavi,

    Can you elaborate on how the the comms is not working? are you getting garbled data? no data at all? There is nothing inside of the module that prevents words less than 16 bits. In the C28x SPI module, there is a requirement to left justify the transmit data if you are sending less than 16 bits. McBSP does NOT have this requirement.

    -Mark
  • Hi Mark,
    it is communicating but im gettng garbage data. here is der hw i configured for RCR1&2 and XCR1&2 register for 8-bit TX RX

    McbspaRegs.RCR2.bit.RPHASE=0;
    McbspaRegs.RCR1.bit.RFRLEN1=0; // 1 frame word
    McbspaRegs.RCR1.bit.RWDLEN1=0; // 8 bit
    McbspaRegs.RCR2.bit.RCOMPAND=0x11; //A-law companding, 8-bit data, MSB received first
    McbspaRegs.RCR2.bit.RFIG=1;
    McbspaRegs.RCR2.bit.RDATDLY=1; //delay 1bit

    McbspaRegs.XCR2.bit.XPHASE = 0;
    McbspaRegs.XCR2.bit.XCOMPAND =0x11; // A-law companding, 8-bit data, MSB received first
    McbspaRegs.XCR2.bit.XFIG = 1;
    McbspaRegs.XCR2.bit.XDATDLY=1; //delay 1 bit
    McbspaRegs.XCR1.bit.XFRLEN1=0; // 1 frame word
    McbspaRegs.XCR1.bit.XWDLEN1=0; // 8 bit transmit


    below instructions are hw im tx and rx data (8-bit)

    while(McbspaRegs.SPCR2.bit.XRDY ==0);
    McbspaRegs.DXR1.all =0x80;


    while(McbspaRegs.SPCR1.bit.RRDY==0);
    data=McbspaRegs.DRR1.all;

    is there any mistakes in configurations please tell me.

    Thanks
    -Gavi Prakash
  • Gavi,

    It looks like you are using the Companding feature of the McBSP, which, when enabled, will encode your data. This is probably why you are seeing "garbled data". Companding is not necessary to enable for standard SPI operation. If you do not plan on using this, please set both XCOMPAND and RCOMPAND to 0.

    Companding is a not a widely used feature. It was mainly used in Telecom systems to compress (and encode) data. If you would like to understand how it works, there is a section in the User Guide which explains how to use it, as well as a (very old) application note linked at the end of this post. Wikipedia also has a decent write up on how and why it is used.

    Thanks,
    Mark

    www.ti.com/.../spra163a.pdf