2015-03-18 03:59 AM
2015-03-18 04:29 AM
2015-03-18 04:50 AM
I suspect that your code does not enter the loop to receive data from Master because of,
if (SPI_I2S_GetFlagStatus(SPI1, SPI_FLAG_RXNE) == RESET)
because RXNE is set to 1 when some data is received => which will be the case when the Master sends some data. Just try setting it to SET and I think it should work.
In the case when it compares the flag status to RESET, no data has been received, so it would enter as long as Master sends no data, but this also means that the data received will be 0 => the green LED should be set always. Is that the case?
2015-03-18 05:00 AM
Hi Francescato,
Hartley, Thank You for your response, I have checked with master part which is working fine and the slave itself is not able to get the data in my logic part. Please if you found any mistakes in my logic and in my slave initialization kindly correct me.2015-03-18 05:06 AM
Hi Kumar,
Thanks for your interest to help me, as you suggested I have made changes fromif (SPI_I2S_GetFlagStatus(SPI1, SPI_FLAG_RXNE) == RESET)
to
if (SPI_I2S_GetFlagStatus(SPI1, SPI_FLAG_RXNE) == SET)
When I have change the condition its not entering into the loop itself, I mean previously the green LED was glowing from the very beginning but at present its not happening too.
2015-03-18 05:21 AM
As Kumar suggests
if (SPI_I2S_GetFlagStatus(SPI1, SPI_FLAG_RXNE) != RESET) // Not Reset, there IS some data
{}I would probably also only send data when TXE is asserted2015-03-18 05:34 AM
Like I said, it would only enter the loop when Master sends something (and hence, it was entering the loop previously and data received was 0x00, so entered the case 0 and stayed there, forever thereafter). If you want it to display the status via LED's, then you can add some code for the 'else' case, i.e, when no data is received, turn the green LED ON (or anything you choose) as an example.
2015-03-18 11:15 AM
Hi Kumar,
You are right, receive_data is considering the 0x00 as soon I reset the board and it is entering the case 0, so green LED is continuously glowing all the time.Even when I press the Master button, it must transmit the value of i ( using SPI1_send(i); ), now the problem in the slave part where receiving the data from master, you have suggested me to do some changes, what kind of changes I can do ?? and can you trace why this is not reading the data from register ?? while(1) { if (SPI_I2S_GetFlagStatus(SPI1, SPI_FLAG_RXNE) == RESET) { uint8_t received_data = SPI_I2S_ReceiveData(SPI1); switch(received_data) {Kindly help me ...2015-03-18 03:47 PM
if (SPI_I2S_GetFlagStatus(SPI1, SPI_FLAG_RXNE) == RESET) // << THIS CODE IS WRONG
No, for the third time... You need to check that the flag is SET, *not* RESET. Set means there's data available for you to read.2015-03-18 09:21 PM
Hello Clivel,
How can I test that the flag is SET, *not* RESET ? Please give me some idea so which helps me a lot