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.

SPI works only in 16bit mode, not 8bit



Hi, I`ve a problem with SPI on 2809. I`ve tried the examples with loopback and with the code written by myself. Actually I have no clue what is wrong, when I set to 16-bit character length there is a transmission on miso/mosi seen on osciloscope, but when I change from 16 to 8 bit char length mosi line is dead.

here is the init spi:

void InitSpi(void){
   SpibRegs.SPICCR.bit.SPISWRESET = 0; // Reset SPI

    SpibRegs.SPIFFTX.all = 0xE040;
   SpibRegs.SPIFFRX.all = 0x204F;
   SpibRegs.SPIFFCT.all = 0x0;
   SpibRegs.SPIFFTX.bit.SPIFFENA = 0;  // Enable FIFO's

   SpibRegs.SPICTL.all = 0x0006;       // Master, Talk enabled
   SpibRegs.SPISTS.all = 0x0000;
   SpibRegs.SPIBRR = 127;              // Baud rate - najwolniejszy

   SpibRegs.SPIPRI.bit.FREE = 1;       // Set so breakpoints don't disturb xmission
   SpibRegs.SPICCR.all = 0x009F;           // Relinquish SPI from Reset, 0 0 |1001| 1111 -> |reset,loop on|


}

some defs:

#define WREN 0x06        /* set write enable latch for NM25C020 */
#define WRDI 0x04        /* reset write enable latch */
#define RDSR 0x05        /* read status register */
#define WRSR 0x01        /* write status register */
#define READ 0x03        /* read data from memory */

#define WRITE 0x02        /* write dato to memory */

#define DUMMY 0x00;

and the example func which I use to test te transmission:

Uint16 ReadStatusEEPROM(void){
    Uint16 stat;
    /* reads status register out of the EEPROM */
    SpibRegs.SPITXBUF = RDSR;                // write opcode into serial shift data register
    while(SpibRegs.SPISTS.bit.INT_FLAG == 0){}
    DELAY_US(100);
    SpibRegs.SPITXBUF = DUMMY;                // write dummy into serial shift data register
    while(SpibRegs.SPISTS.bit.INT_FLAG == 0){}
    stat = SpibRegs.SPIRXBUF;                // receive status of the EEPROM
    while(SpibRegs.SPISTS.bit.INT_FLAG == 0){}
    return(stat);
}

In future I will use spi for communication with eeprom 25lc160 and as I can see I need 8bit communication, because it will be much simplier form me.