How do I synchronize my master with slave using Spi communication? I have generated one more Real time clock(apart from miso,mosi,cs,sck) of 10 ms from master and now I have to sync my slave for each raising edge of the clock, slave has to start reading the data from the senor ( lets from ADC ) and using the time slice (for each 2.5 ms) master request for the data, if slave has the data it will send. Now my problem is in main() i should use while(1) (or should I?) when it reading the data i am not able to make out how much time it will take to read. Is there any other solution for sychronization ? ( I am using LPC1343)
0
votes
It is not clear if you are coding the master or the slave. In case the slave has some form of intelligence, it is custom for it to read data continuously, so that when the master needs it, it is already available and placed in the data buffer used by MISO.
- Lundin
1 Answers
0
votes
Usually SPI ADC are configured to autonomously sample data and flip a IO to indicate to master that data is available, that is captured by an IO interrupt.
If you want your SPI Slave to work synchronously, you have to tell him "sample now" each 10ms. It is called polling.
Your timer interrupt should call a routine that will trigger the polling mechanism.