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);
}
Hi,
Please check and download [FRDM-KEXX Driver Library Package (REV 1.2.1)], which provides KE06 SPI master/slave demo based on FRDM-KE06 board.
FRDM-KE06Z|Freedom Development Platform|Kinetis MCU|NXP
Wish it helps.
Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------