Then I changed the code a bit to send more data (13 bytes). If data transmission is successful and sent data matches the received data then I lit the blue LEDs on the master and slave boards (in the niko_proj/SPI_polling_scb folder). All of this seems to work fine.
However, I need to use non SCB SPI components. So I mimicked the projects from niko_proj/SPI_polling_scb into niko_proj/SPI_polling_non_scb folder, and used non SCB components with their API calls in main.c. Everything builds fine, but the slave doesn't receive anything from master now.
The workspace bundle is attached.
so I changed it to either resistive pull down or up depending on the condition(s) of pins.
so I enabled global interrupt at the beginning of both main.c.
Thanks again for your help! I am sorry that I have to bug you with this. I was assigned to do this at work and I have zero experience doing anything like this: I am not an electrical engineer and don't have any experience writing embedded code. So I am desperate for any help that I can get. Thank you so much for doing this for me!
I made the changes that you recommended and they helped. Now it looks like master and slave receive data from each other. The first transmission from master to slave looks good: all bytes received and they matched to what was sent by the master. Then I noticed the function that received data SPIS_WaitForCommand() would stuck and never return. Declaring tmpBuffer static seems fixed the problem for some reason.
Also, other than the very first transmission from master to slave, the rest do not look good: data are received by slave, but it doesn't match to what master sends. Same problem for master: received data doesn't match to the slave's TX buffer.
Do you have any idea's why the data is corrupt after the very first transmission?
data off by 1. So I created a question/discussion below.
Hopefully someone can teach/help us how to fix/workaround this problem.
With the help of user_78878863-san, I could figure out what the problem was.
This was described in the datasheet of SPIS, which I failed to find.
Places a byte/word directly into the shift register for transmission.
This byte/word will be sent to the master device during the next clock phase.
Required for modes where CPHA == 0 where data must be in the shift register before the first clock edge.
as my memory can not put up with the maze of tmp, dummy... etc.
and buffers SPI_Slave sTxBuffer, sRxBuffer, sFillBuffer.
Master receives sTxBuffer data from slave in sendCmd(). I expect to receive sFillBuffer data here. However readStatus()receives sFillBuffer while I expect to receive the sTxBuffer data here. Also, as you can see bellow, the received data is somehow shifted to the right by one byte.
I attached my current updated workspace bundle in the top post of this discussion.
You can attach your file to a Reply message by using "Use advanced editor" in the right top of reply pane.
nor none one can trace the changes made during the discussion.
I read and tested your new code.
on the other hand Master is waiting for salve to prepare only 50us!
So I reactivated the SPIS_WriteTxDataZero() function.
I attached the main.c for the slave.
the code seems to work correctly now. Thank you so much for all your time and effort to help me solving this problem!
If you don't mind, I'd like to ask you two quick questions.
1. If I need to run a multiple of SPI buses on a same device, then do I just copy the components with their code and add new pins or is there more to it than that?
2. I've noticed that it lets me adding additional CS lines only with the SPI SCB component. Does it mean that that SPI non SCB handles only one chip select line?
then do I just copy the components with their code and add new pins or is there more to it than that?
this means the code must be modified to reflect the name, too.
Note: Depending on the device there are some maximum number of same components we can add.
2. I've noticed that it lets me adding additional CS lines only with the SPI SCB component.
Does it mean that that SPI non SCB handles only one chip select line?
We don't have to use component's CS line for chip select.
device are being called, then de-assert the CS line.
P.S. In my sample project below, I was using GPIO CS for TFT as TFT_CS.