SPI Multi Slave Communication

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SPI Multi Slave Communication

705 Views
joginderrana
Contributor II

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.

Labels (1)
0 Kudos
1 Reply

343 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

To investigate your problem correctly and efficiently, please provide us the follows: 1. your CW version: Start the IDE and click on Help | About CodeWarrior Development Studio. Send me the version and build id. 2. send the entire sample code folder(include .project, prm,c...) in zip format to me. so that i can test it on my side directly. 3.      error screenshot. thanks!

0 Kudos