9 years, 5 months ago.

SPI slave

Hi,

I am trying to make PIC16f877A a SPI master to MBED LPC1768. I am facing a strange problem I keep SSEL low during transfer in mode 1 but the MBED doesn't recieve any data work but strangely when the i disconnect the SSEL signal and leave the wire in air the mbed recieves the data and as soon as it is connected back to the input pin again no reception of MOSI data. Another issue is the data I am sending from PIC is 0X55 and sometimes the MBED recieves 0X55 as data and sometimes it recieves 0XAA (when I disconnect the SSEL).

Regards, Kishwar

1 Answer

9 years, 5 months ago.

The SPI slave engine does not accept the data until SSEL is taken hi again. At that time mbed recognizes that you have completed sending the whole byte. So, the master should make SSEL low, then send the byte, and then take SSEL high again. Disconnecting the wire of SSEL effectively looks to mbed SPI engine as pulling SSEL high again and so it shows you the received data. The mixup between 0x55 and 0xAA could be a spurious SCLK (the data is shifted by one position), perhaps you have also mixed up the modes (capturing the data on rising or falling edge of SCLK).

Accepted Answer

I am sorry forgot to mention I do make the SSEL line HIGH after transfer but still do not recieve any data till i unplug the ssel wire . The PIC is set to 20MHZ clock and the SPI is FOSC/16 so 1.25 MHz. The PIC SPI clock is set to be IDLE LOW and send data at ACTIVE to IDLE transistion which in this case is the falling edge. If I understand this correctly that is mode 1 of MBED SPI clock or am I making a mistake

Thankyou

posted by fatima kishwar 21 Jun 2015

Check that you have a good common GND connection between the sender and the receiver side. When disconnecting the SSEL wire results in the data being received that could be caused by unwanted currents between the data and clock lines. Also make sure to use the correct SSEL pin p8.

posted by Wim Huiskamp 22 Jun 2015

Thankyou so much you were right it was a ground issue or rather a hardware issue

posted by fatima kishwar 25 Jun 2015