Sergey Pilipchuk

SPI Transmission Gaps between each byte sent

Discussion created by Sergey Pilipchuk on May 3, 2011
Latest reply on May 13, 2011 by Sergey Pilipchuk

Hello everyone,

 

I am fairly new to C programming and right now trying to utilize the SPI interface to control EEPROM (FM25640) with MC9S08JM60. The issue that I am having is that there are gaps between each byte sent by the SPI. My guess is that he gaps are created by checking the SPTEF flag (transmit buffer empty flag) before sending next byte. Is this normal?? Shouldn't the the data and clock be seamless?

 

I have SPI interrupts disabled, 8 bit mode, SPI mode 0, SPI frequency is set to 2MHz, data sent MSB first.

 

I attached the logic analyzer picture of the signals.

 

Also here is a sample code from my application, this is a memory WRITE function:

 

void RAM_WRITE(word adrs, byte data){  byte ADH=0,ADL=0;  //split 16-bit address into two 8-bit parts    ADH=adrs >> 8;  ADL=(adrs & 0x00FF);  CS=0;                         //enable FM25640; pull chip select low  while(SPI1S_SPTEF!=1);        //wait until transmit buffer is empty    SPI1DL=WRITE;                 //send the WRITE TO MEMORY command  while(SPI1S_SPTEF!=1);        //wait until transmit buffer is empty   SPI1DL=ADH;  while(SPI1S_SPTEF!=1);        //wait until transmit buffer is empty   SPI1DL=ADL;  while(SPI1S_SPTEF!=1);        //wait until transmit buffer is empty     SPI1DL=data;  dly(7);  CS=1;                         //disable FM25640; pull chip select high }

Outcomes