SPI 8 byte Limit ?????

26 Nov 2012

Hi ,

I have successfully interfaced two mbed(Master and Slave) through SPI interface and got continuous data from Master to slave at 1MHZ and Mode 0.

But When I replaced Master as MSP430 instead of mbed and operating at 500KHZ and Mode 0.I can get only 8 bytes of data.

I have checked the MSP430 board with scope which is correctly giving the SPI data.But mbed only not receiving the data after 8th byte .

Kindly suggest what may be the problem ???

26 Nov 2012

Hi, I assume you have set the mbed to receive a larger data packet? i.e.

spi.format(16,0);  // Set up SPI port to receive 16 bit data packet
26 Nov 2012

The FIFO on the SPI is 8 frames long. Is it possible that you aren't reading the data out fast enough and this buffer is getting full? This could happen if you are doing quite a bit of processing between each call to the read() method in the mbed slave code.

05 Dec 2012

Hii can you please send your code..

05 Dec 2012

hii balaganesh Can you please share your master and slave code..

05 Dec 2012

Hrishikesh Bhagwat wrote:

hii balaganesh Can you please share your master and slave code..

05 Dec 2012

This is my receiver code and my Master code works perfectly.

  1. include "mbed.h" SPISlave device(p5,p6,p7,p8); Serial pc(USBTX,USBRX); int main() { device.reply(0x59); char arr; pc.printf("SPI RECEIVER TESTING\r\n"); device.frequency(1000000); device.format(8,0); while(1) { if(device.receive()) { arr = device.read(); device.reply(0x59); pc.printf("The received Data is %c\r\n",arr); } } }
05 Dec 2012

thanks but what about transmitter code?

05 Dec 2012

Hrishikesh Bhagwat wrote:

thanks but what about transmitter code?

05 Dec 2012

/media/uploads/steupgrade/new_text_document.txt

Hi its dificult to read.But any way i have attached it. But its working correctly.

05 Dec 2012

Hrishikesh Bhagwat wrote:

Hrishikesh Bhagwat wrote:

thanks but what about transmitter code? because i need to see master coding also according to that some changes will be done in slave..

05 Dec 2012

u said u have done programming of two mbed's one as master and one as slave.. i need to see that programming code for both master and slave.. thanks

05 Dec 2012
  1. include "mbed.h" SPI spi(p5,p6,p7); DigitalOut cs(p8); Serial pc(USBTX,USBRX); int main() { int j; char arr[]="HELLO"; char rec; spi.format(8,0); spi.frequency(1000000); pc.printf("SPI data transfer Initiated\r\n"); while(1) { j=0; do{ cs = 0; rec=spi.write(arr[j]); wait_ms(2); cs = 1; if(rec=='Y') { pc.printf("Written Data is %c\r\n",arr[j]); j++; }

}while(j<=4); } }

05 Dec 2012

If you want to view code correctly then use the code tags:

< < code > > your code here < < /code > >

without the spaces between the greater than and less than characters, so you get:

include "mbed.h"
SPI spi(p5,p6,p7);
DigitalOut cs(p8); 
Serial pc(USBTX,USBRX); 
int main() { 
    int j; 
    char arr[]="HELLO"; 
    char rec; 
    spi.format(8,0); 
    spi.frequency(1000000); 
    pc.printf("SPI data transfer Initiated\r\n"); 
    while(1) { 
        j=0; 
        do{  
            cs = 0;
            rec=spi.write(arr[j]);
            wait_ms(2);
            cs = 1;
            if(rec=='Y') { 
                pc.printf("Written Data is %c\r\n",arr[j]); 
                j++; 
             } 
        }while(j<=4);
    }
}

Hope this helps

Andy

11 Sep 2013

no more news on that? I have the same problem

11 Sep 2013

It is important you toggle the cs line after every byte you sent.

23 Oct 2013

I have the same issue. Nothing change with toggle the cs line... news ?