I am a college student working on my final project. Here, i need to do communication between microcontroller using SPI. The general step of the communication is as follows :
1. Master send command to slave
2. Slave interprets the command received from master. Then, it will do one of the following
a. Do some tasks
b. "Send" data to master (prepare data in SPI register, waiting to be shifted by master's dummy data)
3. Master shift the data from slave using dummy data (if it previously asks for data)
So far i only manage to do step 1. The main problem is, I cannot find the best scheme to be used by master when it waits for the slave to interprets the command. I have tried to do simple handshaking by pulling one port high when the slave has prepared the data, and while the port is still low, the master waits, does nothing. Using this scheme, i have managed to send data from slave to master, but the data i get is not the right data.
Can you give me some advice please?
Note : I use MCF51JM128 as master and Atmel ATmega16 as a slave