spi master - slave communication

(instructions, reset, WDT, specifications...) PIC17Cxx, PIC18Fxxx

spi master - slave communication

Postby beyazit » Tue Jul 22, 2014 10:48 am

hi guys...
i have a problem with spi master and slave communication.
i have one master and three slaves. pics are 18f452.
when i send data from master slaves read properly.
but but when try to send data from slave it seems like data shifted rigth
and when i try shift left before send data on the master side it adds 1 to 7th bit.
S is 0b01010011
it becames 0b11010011 on master.
i make &0b01111111 on master side. but this will loose 7th bit

headers are from microchip standard.
and all necessary lines are connected.

here is the master:
while (1) {
unsigned temp = SSPBUF;
ss1 = 0;
Delay10KTCYx(10);
SSPBUF = 40; // junk

while (!BF);
PORTD = (SSPBUF & 0b01111111);
Delay10KTCYx(10);
ss1 = 1;



here is the slave....

void interrupt ISR()
{
if (SPI_Intr_Status == 1)
{
if (SSPOV)
{
SSPOV = 0;
}
else
{
if (SSPSTATbits.BF)
{
PORTD = SSPBUF;

SSPBUF = ('S'<<1);
}
}
SPI_Clear_Intr_Status_Bit;
}
}


any help will be nice :)
beyazit
 
Posts: 2
Joined: Tue Jul 22, 2014 10:14 am
PIC experience: Experienced Hobbyist

Re: spi master - slave communication

Postby beyazit » Tue Jul 22, 2014 11:27 am

i have found the solution...

if needed i am writing here as a reference...

my polarisation mode was MODE_10
but the data is started to send on falling edge...
so i don't what happens but
when i changed the polarisation to MODE_01
both send receive correct values...

well...

best.
beyazit
 
Posts: 2
Joined: Tue Jul 22, 2014 10:14 am
PIC experience: Experienced Hobbyist


Return to 16-Bit Core

Who is online

Users browsing this forum: No registered users and 9 guests