Setting Control Register Bits over SPI

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times

Setting Control Register Bits over SPI

Post by Jay Dee »

Hi guys,
I have a peripheral SPI IC and need to set the control registers bits
There are 3 control registers, each 32 bits in length.
Using the legacy SPI component can i simply send the string of bits in one go or do I have to send a single byte at a time?
would the following work using SPI_Send_Char
0x8FFFFF71
or even
0b00011111111111111111111111101000

Or do I need to do four seperate SPI_Send_Char opertions to get the 32 bits sent?
Thanks,
J.

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times

Re: Setting Control Register Bits over SPI

Post by kersing »

SPI_Send_Char sends one byte (8 bits) only. So you need to call it 4 times to send 32 bits.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times

Re: Setting Control Register Bits over SPI

Post by Jay Dee »

Hmm, Yep..I had a play with the simulation and got that result.
Then played with using the SPI_Send_String but not sure I can convert the Hex values to a string easily...so it might just be a case of sending each byte in turn. Shame as i need to send 32 bytes.

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: Setting Control Register Bits over SPI

Post by Benj »

Hi Jay dee,

Why not create a macro with an unsigned long as a parameter, then split the long up into bytes inside the macro and send using 4 SPI component macros. This way you can use one icon to pass the entire 32-bit number.

This article details converting between bytes and larger variable types.
http://www.matrixmultimedia.com/article.php?a=366

Post Reply