NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » How do I send number values on SPI?
February 06, 2012 by sask55 |
This should be simple. I am attempting to send a series of higher precision large number values from a slave to the master on the SPI connection. The values I have are held as int32_t type variables in the slave but will eventually end as Double type variables after some necessary mathematical calculations are done using their values. The values can be sent and read at the master as ether int32 or double type numbers. The problem I am having is trying to represent ether one of these number type variables as a string of one byte variables. Or; to but It another way how do I send these multiple byte variables numbers as a sequence of one byte transitions over the SPI? I will require the values to be held as numbers again on the master after they are received completely. |
---|---|
February 06, 2012 by pcbolt |
@sask55 Will something like this work:
|
February 07, 2012 by sask55 |
Yes I think that may work. I should just shift in increments of 8 to break up or construct the larger variables. The data stream is originating from digital calliper outputs. This data is read by the slave MCUs as a continuing stream of 24 bit serial outputs. I was reading the calliper output into an int32_t variable. I can see that it may make more sense to read the calliper output into sets of three uint8 variables. I should then be able to send the sets over the SPI and fill the 24 LSB of an int32 variable for each reading. I could then do the math required to interpret the readings coming from all three of the slaves in the master MCU. Thanks. |
Please log in to post a reply.
Did you know that you can make a capacitive proximity sensor with some aluminum foil and paperclips? Learn more...
|