Page 1 of 1

Setting Control Register Bits over SPI

Posted: Sat May 25, 2013 3:53 pm
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.

Re: Setting Control Register Bits over SPI

Posted: Sat May 25, 2013 4:43 pm
by kersing
SPI_Send_Char sends one byte (8 bits) only. So you need to call it 4 times to send 32 bits.

Re: Setting Control Register Bits over SPI

Posted: Sat May 25, 2013 6:46 pm
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.

Re: Setting Control Register Bits over SPI

Posted: Mon Jun 17, 2013 8:00 pm
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