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.
Setting Control Register Bits over SPI
Moderator: Benj
-
kersing
- 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
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
― C.S. Lewis
Re: Setting Control Register Bits over SPI
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.
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.
- 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
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
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
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel