SPI module as a slave

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
User avatar
Bruno
Posts: 67
Joined: Thu Jan 18, 2018 2:11 pm
Been thanked: 21 times
Contact:

SPI module as a slave

Post by Bruno »

Hello at all
I have a question about PIC's spi module.
I am using a pic18F46k22 with spi module in slave mode but I have synchronization problems with the bytes I send from the master.
I have found an unorthodox way to synchronize received bytes, but sometimes this doesn't happen
This is the first time I use this mode of operation and I can't solve it.
Can someone help me
I am attaching the test file I am using

Thank you
Attachments
SPI_Test_46K22_1.1.fcfx
(16.16 KiB) Downloaded 108 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SPI module as a slave

Post by Benj »

Hi Bruno,

First I would do a 1 second flasher test just to confirm you are running at the top speed of 64MHz. It could be the device is running slower then you think.

If the device is running at the right speed then what rate is the master sending out the SPI, could this be slowed down?

I have developed a SPI slave device and remember having similar problems, I may have ended up having to add small delays between the bytes sent by the master to allow the slave to keep up.

User avatar
Bruno
Posts: 67
Joined: Thu Jan 18, 2018 2:11 pm
Been thanked: 21 times
Contact:

Re: SPI module as a slave

Post by Bruno »

Hi Benj
Thank you for your support.
I checked the frequency of the micro and it is correct: I try to put some delays between the data sending macros, as you suggested.
Is there a better way to read the data than I did?
I tried to make a connection between two micro in I2C, one as master and one as slave, and everything works fine. Instead in SPI, when I start the micro, the bytes I receive on the slave are not always in the position where the master sends them.

best regards

Post Reply