I get the SPCR values to be displayed on the screen just fine with the command below, but I couldn't copy them into a string variable (that should possibly also contain leading zero(s)).
Serial.print(SPCR, BIN);
Kind of feel dumb to ask - your advice is certainly appreciated.
May be it's better to formulate my question in a different way.
We know that all SPI settings are determined by the Arduino SPI Control Register (SPCR).
The question is:
How can I read out values for each of the specifc bits and store each of them into a different variable?
In SPI these bits are:
SPIE, SPE, DORD, MSTR, CPOL, CPHA, SPR1, SPR0
I'd like the values to displayed on screen and then be put into string-variables named like:
v_SPIE, v_SPE, v_DORD, v_MSTR, v_CPOL, v_CPHA, v-SPR1, v_SPR0.
Displaying the values of SPCR on screen is not a problem, except the leading zero's are omitted. The command is Serial.print(SPCR,BIN);
How can I avoid leading zero's?
How can I read each bit separately?
Your code is for SPE and SPIE.
I am also seeking the values for all other bits.
I mean the values 0x80 or 0x40 are conditional, aren't they?
But then that's true too, because they're either 1 or 0 for each bit.
So I guess I have to query for the two possible states for each bit, right?
Your code is for SPE and SPIE.
I am also seeking the values for all other bits.
So I guess I have to query for the two possible states for each bit, right?
That's right - you didn't expect me to write it all for you, did you?
That was just an example.
Another more general way of doing it would be to put the strings into an array of eight, then you could use the bit number as a subscript, and either print or store the strings as you want.