SPI Speed Setup.

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
Synergy6
Posts: 28
Joined: Wed Jan 18, 2017 3:38 pm
Been thanked: 4 times

SPI Speed Setup.

Post by Synergy6 »

Hi.
Is it possible to change SPI speed mid code?

My PIC is running at 64MHz (PIC18) and i need the SPI bus to run at <11MHz on startup.
After some initialisation code it needs to run at as close to 30MHz as possible, but not faster.

Can anyone give info on how to go about this?

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 Speed Setup.

Post by Benj »

Hello,
Is it possible to change SPI speed mid code?
Yes.
Can anyone give info on how to go about this?
Are you using Flowcode or C? If Flowcode then what version?

An 8-bit PIC running at 64MHz will have an instruction rate of 16MHz, I beleive the fastest SPI prescaler is /4 again so that will give you an absolute max SPI bit speed of 4MHz.
So maybe this speed can be used for everything?

Synergy6
Posts: 28
Joined: Wed Jan 18, 2017 3:38 pm
Been thanked: 4 times

Re: SPI Speed Setup.

Post by Synergy6 »

Hi,

This would be done in flowcode.
Currently using demo of V7. Have been talking with Steve briefly about our requirements

OK, so 4MHz looks like it will cover everything.

We will be moving this over to PIC32 soon, is there much difference. I expect the instruction rate will change as will the spi prescaler.

Its the PIC32MZ Series that we are considering using as they run pretty quick.

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 Speed Setup.

Post by Benj »

Ok thanks that helps things.

The Flowcode 7 SPI component has a macro allowing you to re-configure the SPI prescaler on the fly during runtime.

8-bit PICs generally always have a /4 on the master clock.

16-bit PICs can vary but it is generally /2 or /4.

32-bit PICs seem to have a /2 but I could be wrong on this, I need to play more with them.

We are close to bringing out the ST ARM chip pack also which seems to have a /1 similar to AVR chips.

Post Reply