Hi
Still i am facing prpblem.
below is my code for slave and master
//SLave Code
void init_SPI0_SLAVE(void)
{
// PCONP |= 0x00000400 ;
PINSEL1 |= 0x00001500;
IODIR0 &= ~(0x00000080) ; //CS configured as input
//MOSI
S0SPCCR = 16; //Set SPI clock to 15Mhz/16 = 937.5kHz
//CPOL=0, CPHA=1, interrupt enable
S0SPCR = 0x10; //SPI in Slave Mode, LSB first,
}
unsigned char slave_getchar_spi0(unsigned char cData)
{
unsigned char info = 0;
while(!(S0SPSR&0x80)); //Wait while busy
info=S0SPDR ;
S0SPSR&=(~(0x80));
S0SPDR = cData; //Read received byte
return(info);
}
Master code
void init_SPI0_master(void)
{
PINSEL1 |=0x00001500;
IODIR0 |=0x00000080 ; //CS is configurea as output, all other SPI PIN are set as spi mode pin
S0SPCCR = 16; //Set SPI clock to 15Mhz/16 = 937.5kHz
// S0SPCR = 0xA8; //SPI in Master Mode, MSB first,
//CPOL=0, CPHA=1, interrupt enable
S0SPCR = 0x30; //SPI in Master Mode, MSB first,
}
unsigned char master_getchar_spi0(unsigned char cData)
{
unsigned char info = 0;
IOCLR0 =0x00000080; //Select chip
S0SPDR =cData ; //Dummy write
while(!(S0SPSR&0x80)); //Wait while busy
S0SPSR&=(~(0x80));
info = S0SPDR; //Read received byte
IOSET0 = 0x00000080; //Deselect chip
return(info);
}
the above code i download in to Master and slave board.
code is not working at all , i am checking clock and data line , but no pulse
and also i want to know the connection between master , please confirm which one is correct
Connection 1:
Master Slave
SCK SCK
MOSI MISO
MISO MOSI
SSEL SSEL
or
Connection 2:
Master Slave
SCK SCK
MOSI MOSI
MISO MISO
SSEL SSEL
which one is correct?
Best regards
Ramasamy
---------- Post added at 13:09 ---------- Previous post was at 12:41 ----------
Hi
Still i am facing prpblem.
below is my code for slave and master
//SLave Code
void init_SPI0_SLAVE(void)
{
// PCONP |= 0x00000400 ;
PINSEL1 |= 0x00001500;
IODIR0 &= ~(0x00000080) ; //CS configured as input
//MOSI
S0SPCCR = 16; //Set SPI clock to 15Mhz/16 = 937.5kHz
//CPOL=0, CPHA=1, interrupt enable
S0SPCR = 0x10; //SPI in Slave Mode, LSB first,
}
unsigned char slave_getchar_spi0(unsigned char cData)
{
unsigned char info = 0;
while(!(S0SPSR&0x80)); //Wait while busy
info=S0SPDR ;
S0SPSR&=(~(0x80));
S0SPDR = cData; //Read received byte
return(info);
}
Master code
void init_SPI0_master(void)
{
PINSEL1 |=0x00001500;
IODIR0 |=0x00000080 ; //CS is configurea as output, all other SPI PIN are set as spi mode pin
S0SPCCR = 16; //Set SPI clock to 15Mhz/16 = 937.5kHz
// S0SPCR = 0xA8; //SPI in Master Mode, MSB first,
//CPOL=0, CPHA=1, interrupt enable
S0SPCR = 0x30; //SPI in Master Mode, MSB first,
}
unsigned char master_getchar_spi0(unsigned char cData)
{
unsigned char info = 0;
IOCLR0 =0x00000080; //Select chip
S0SPDR =cData ; //Dummy write
while(!(S0SPSR&0x80)); //Wait while busy
S0SPSR&=(~(0x80));
info = S0SPDR; //Read received byte
IOSET0 = 0x00000080; //Deselect chip
return(info);
}
the above code i download in to Master and slave board.
code is not working at all , i am checking clock and data line , but no pulse
and also i want to know the connection between master , please confirm which one is correct
Connection 1:
Master Slave
SCK SCK
MOSI MISO
MISO MOSI
SSEL SSEL
or
Connection 2:
Master Slave
SCK SCK
MOSI MOSI
MISO MISO
SSEL SSEL
which one is correct?
Best regards
Ramasamy