AnsweredAssumed Answered

PROBLEM WITH SPI COMMUNICATION USING FRDMKE06Z

Question asked by DIVYA M S on Oct 26, 2017
Latest reply on Nov 1, 2017 by Hui_Ma

I am using two numbers of  MKE06ZI28VLK4 processor ICs,one as master and the other one as slave for SPI communication.The master is transmitting data properly , but the slave is not receiving the transmitted data.It always shows zeros in the receive data register. I am sure that the connections and register configurations are done properly.

MASTER

void register_write(uint8_t value)
{

if(SPI0_S & SPI_S_SPTEF_MASK )
{

spi_transfer_one_byte(value);
}

}

void spi_transfer_one_byte(uint8_t v)
{
uint8_t temp_data;


SPI0_D = v;

}

main.c

int main(void)
{
PE_low_level_init();
SPI0_mstrInit();
for(;;) {

register_write(0x54);
register_write(0x00);

for(uint8_t i=0; i<20;)
{
i=i+1;
}

}

SLAVE

uint8_t register1_read()

{
uint8_t value_2;
uint8_t value_3= 0x45;
if(SPI0_S & SPI_S_SPRF_MASK)
{
value_2 = SPI0_D;
return value_2;
}

return value_3;
}

main.c

int main(void)
{
PE_low_level_init();
UART0_Init();
SPI0_mstrInit();
/* Write your code here */
for(;;) {
uint8_t data;
data = register1_read();
UART_tx(data);
}

Outcomes