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.

how to communicate 8 bit data in spi protocol from piccolo f28069

Other Parts Discussed in Thread: MSP430G2553

Dear all,

i want to communicate 8 bit data in spi protocol from piccolo f28069 to msp430g2553 because msp430g2553 has 8-bit data spi but piccolo is an 16 so i want to communicate 8 bit data from piccolo to msp430

i made some trials

SpiaRegs.SPICCR.all =0x000F;             // Reset on, rising edge, 16-bit char bits

SpiaRegs.SPICCR.all =0x009F;         // Relinquish SPI from Reset  

so last 4 lsb bits will tell the size of data so if change this 4 lsb other than f it will not work at all   

  • Pradeep,

    This should be possible.  You just need to setup both devices for 8 bit data width.  Try setting those last four bits of SPICCR to 0x7.

    Regards,
    Trey

  • reading sprug71b.pdf (page 30) I see that the sending buffer SPITXBUF must be left-justified. and since his data is 8bit, it should be something like 

    SPITXBUF=(data_to_Send <<8);

    ins't it? or is it just sufficient to put the SPICCR register to 8bit character length? 

  • Dear Emanuel Eni,


    thanks for reply and i done the communication of 8 bit in piccolo. i observed that what ever the length the first bit coming out is msb that is 16 bit so we need to shift over msb bit to 16 bit like i m using 8 bit communication so i need to shift 8 bit to 16 bit before sending the  SPITXBUF so that 8 bits are shifted to 16 to 9 bits and what ever u suggested is also right    

  • Hi Pradeep and TI community,

    I am also trying to use Piccolo spi for 8 bit communication. SPIB is acting as master. I have wired issue that MISO line is always high but data is pushed onto MISO line.

    Can you review below code based on your experience:

    ================================

    GPIO init - for clk, miso and mosi.

    GpioCtrlRegs.GPAMUX2.bit.GPIO24 = 3; // Configure GPIO24 as SPISIMOB
    GpioCtrlRegs.GPAMUX1.bit.GPIO13 = 3; // Configure GPIO13 as SPISOMIB
    GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 3; // Configure GPIO14 as SPICLKB

    GpioCtrlRegs.GPAPUD.bit.GPIO24 = 0; // Enable pull-up on GPIO24 (SPISIMOB)
    GpioCtrlRegs.GPAPUD.bit.GPIO13 = 0; // Enable pull-up on GPIO13 (SPISOMIB)
    GpioCtrlRegs.GPAPUD.bit.GPIO14 = 0; // Enable pull-up on GPIO14 (SPICLKB)

    GpioCtrlRegs.GPAQSEL2.bit.GPIO24 = 3; // Asynch input GPIO24 (SPISIMOB)
    GpioCtrlRegs.GPAQSEL1.bit.GPIO13 = 3; // Asynch input GPIO13 (SPISOMIB)
    GpioCtrlRegs.GPAQSEL1.bit.GPIO14 = 3; // Asynch input GPIO14 (SPICLKB)

    ===============================

    SPI initialization

    void SPI_Init(void)
    {

    EALLOW;

    SpibRegs.SPICCR.all =0x000F; // Reset on, rising edge, 16-bit char bits
    SpibRegs.SPICTL.all =0x000F; // Enable master mode, normal phase,
    // enable talk, and SPI int disabled.
    SpibRegs.SPIBRR =0x007F;
    SpibRegs.SPICCR.all =0x0007; // Relinquish SPI from Reset
    SpibRegs.SPIPRI.bit.FREE = 1; // Set so breakpoints don't disturb xmission
    SpibRegs.SPICCR.bit.SPISWRESET = 1;

    EDIS;
    }

    ================

    SPI read and SPI write API

    Uint16 SPI0_Read()
    {

    SpibRegs.SPITXBUF=(0x00<<8);

    while(SpibRegs.SPISTS.bit.INT_FLAG !=1) { }
    rdata = (Uint16)(SpibRegs.SPIRXBUF);
    rdata = (rdata>>8);
    return (rdata);

    }

    Uint16 SPI0_Write(Uint16 data)
    {
    Uint16 rdata;
    SpibRegs.SPITXBUF=(data<<8);

    while(SpibRegs.SPISTS.bit.INT_FLAG !=1) { }
    rdata = SpibRegs.SPIRXBUF;

    }

    Thanks for your help.

    Below is pic of output i am getting. (1 is clock, 2. is CS, 3 is MISO, and 4 is MOSI)