AnsweredAssumed Answered

SPI Multi Slave Communication

Question asked by Joginder Rana on Mar 31, 2014
Latest reply on Apr 18, 2014 by ZhangJennie

HI, I am very new to Freescale Kinetic microcontrollers. I am working on FRDM-k20d50m development board and trying to develop an application to interface two slaves on this development board. My requirement is to send data to 1st slave and then receive data from the same slave and then to deploy same operation on 2nd slave. If I am using one slave at a time and disconnect the other one then it works fine but if I connect two slaves the at same time I am not receiving any data from slave. The basic code to initiate SPI communication between two slaves is as below:

 

/* Below block of code writes/reads data from first slave*/

 

  SM1_SelectConfiguration(SPI, ChipSelect, AttributeSet);

  SM1_SendBlock(SPI, out_data, sizeof (out_data));

  SM1_ReceiveBlock(SPI, &in_data, sizeof (in_data));

 

  /* Below block of code writes/reads data from second slave*/

 

  SM1_SelectConfiguration(SPI, ChipSelect_1, AttributeSet_1);

    SM1_SendBlock(SPI, out_data, sizeof (out_data));

        SM1_ReceiveBlock(SPI, &in_data_1, sizeof (in_data_1));

 

Please help me to make the communication possible with two slaves at the same time with proper toggling.

Outcomes