General SPI Question /Confusion

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

General SPI Question /Confusion

Post by QMESAR »

Hi All.

Can some one please help me out here
I want too communicate between a PIC16F1938 and a PIC16F1704 with SPI the 1938 is the Master and the 1704 is the Slave,
I understand that the Master is controlling the SCK(Clock) an the Slave will transmit and Receive the Data on the SCK pulses,
My confusion is if for example the master is running a Clock speed of 20Mhz and the SPI clock is configured as FOSC/64 = 312500Hz and the Slave is Running 500Khz( this is because it must only do a PWM at 10Hz) will the Slave still receive the data correctly as there is a huge difference in Clock speeds.

My guess is yes as the SLAVE SPI is controlled by the clock of the Master however i want to check with you guys before I loose hours trying to ride a dead horse Any thoughts on this is appreciated :D

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: General SPI Question /Confusion

Post by Benj »

Hi Peter,

I believe this should be ok.

The only problem I can think of might be that the Master will have to ensure there is enough time between sending SPI bytes to ensure the slave has enough time to receive and process the transferred value.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: General SPI Question /Confusion

Post by QMESAR »

Thanks Ben,
i will give it ago and see :D

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: General SPI Question /Confusion

Post by QMESAR »

Hi Ben.

Just to give some feed back to the question asked here ,it is working well communication with the Slave at such slow OSC speed as you mentioned a person must just allow time for the slave to process the data.the SPI coms are running now a few hours on the bench :D

Thanks again for your help an advise :D

Post Reply