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.

CCS/TMS320F28377S: 28377 McBSP work as SPI master the transmit problem

Part Number: TMS320F28377S

Tool/software: Code Composer Studio

I want to use the McBSP,and config it as SPI,and now,the SPI can work in correct timing sequence,but I cannot transmit what I want to.

This is I want:one frame has 6 words,each words has 8-bit.

I do not know how to transmit my data(for example:0x123456789ABC). And the wave should like figure 1(I missed  one word in the fig ).

But now, what I can see in the logic analyzer is like :

this is my transmit part code:

    char x[6]={0x12,0x34,0x56,0x78,0x9a,0xbc};
    for(i=0;i<6;i++)
    {    
    while( McbspbRegs.SPCR2.bit.XRDY == 1 )
    {McbspbRegs.DXR1.all=x[i];}
    DELAY_US(15);
    }

if I do not use the DELAY_US function,the wave shape is:

it is 7 words,but all words are same.

if I write transmit once,it will send 6 words but but all words are same.

I dont know how to transmit and config the register or is there wrong with my config?

My code like this:

    McbspbRegs.SPCR2.all=0x0000;         // Reset FS generator, sample rate generator & transmitter
    McbspbRegs.SPCR1.all=0x0000;         // Reset Receiver, Right justify word, Digital loopback dis.
    McbspbRegs.PCR.all=0x0F08;           //(CLKXM=CLKRM=FSXM=FSRM= 1, FSXP = 1)
    McbspbRegs.SPCR1.bit.DLB = 0;
    McbspbRegs.SPCR1.bit.CLKSTP = 3;     // Together with CLKXP/CLKRP determines clocking scheme
    McbspbRegs.PCR.bit.CLKXP = 0;        // CPOL = 0, CPHA = 0 rising edge no delay
    McbspbRegs.PCR.bit.CLKRP = 0;
    McbspbRegs.RCR2.bit.RDATDLY=0;      
    McbspbRegs.XCR2.bit.XDATDLY=0;      
    McbspbRegs.RCR2.bit.RFIG=1;      
    McbspbRegs.XCR2.bit.XFIG=1;      

    McbspbRegs.RCR1.bit.RWDLEN1=0;       // 8-bit word
    McbspbRegs.XCR1.bit.XWDLEN1=0;       // 8-bit word
    McbspbRegs.RCR1.bit.RFRLEN1=6;       // 6 word
    McbspbRegs.XCR1.bit.XFRLEN1=6;       // 6 word

    McbspbRegs.SRGR2.all=0x2000;         // CLKSM=1, FPER = 1 CLKG periods
    McbspbRegs.SRGR1.all= 0x0063;        // Frame Width = 1 CLKG period, CLKGDV=

    McbspbRegs.SPCR2.bit.GRST=1;         // Enable the sample rate generator
    delay_loop();                        // Wait at least 2 SRG clock cycles
    McbspbRegs.SPCR2.bit.XRST=1;         // Release TX from Reset
    McbspbRegs.SPCR1.bit.RRST=1;         // Release RX from Reset
    McbspbRegs.SPCR2.bit.FRST=1;         // Frame Sync Generator reset

  Is there anyone can give me some advice or some example code I can refer to?? thank you!!

  • Hello,
    I am writing to let you know that a C2000 team member has been assigned to this post and should be answering shortly.

    Regards
    Baskaran
  • Hi Wei Liu,

    I want to confirm the issue with the waveform that you are showing on the logic analyzer. Is the issue the delay between transmissions and you are wanting to eliminate that? Or are you troubleshooting why you are not seeing the 0xbc transmission?

    Regards,
    Kris
  • HI,
    I want to see the 0xbc in my waveform.and the delay is a way that I want to see what will be different between add delay and not.
    In my view,I do not know whether it is right or not,when I add delay,it will start different frame,so what I watch in the second picture is different frames,not one frame, and it is not right to catch what I want.

    PS: what I said when I set the frame length register to 6,it is 7 words one frame,I have understood this point I ask in my question.

    what i want is one frame and different words in it.I don't know how to config it.
    I refer to some books, does it relate to the MCR1 and MCR2?Should it config multi channel?And can you give me some example code about using McBSP in AUDIO collecting,what I can refer to?
    MY EMAIL:735760576@QQ.COM
    THANK YOU!!
    LIU WEI