Thursday 15 May 2014

microcontroller - Putting a variable of type 'float' on the I2C bus


I'm trying to put a variable that is initially not on the I2C bus, to the I2C bus. However, my variable is of type 'float' whereas the RXData/TXData variables on the I2C bus are of type uint_8t. Do I need to convert my 'float' variable to 'uint_8t' in order to transfer this variable throughout my I2C bus and if so how can I do it? This is what I have tried so far, where writeByte is my 'float' variable and pointer is the register address I want to modify. I'm using MSP432P401R and TI's driverlib library.


/* Initiate start and send first character */
I2C_masterSendMultiByteStart(EUSCI_B0_BASE,
(unsigned char)( ((writeByte>>8) & 0x0F) | ((pointer << 4) & 0x30) ) );

/* Finish transcation */
I2C_masterSendMultiByteFinish(EUSCI_B0_BASE,

(unsigned char)(writeByte & 0xFF));

But I can't seem to get it working. I'd appreciate any help. Thank you in advance and have a great day.




No comments:

Post a Comment

arduino - Can I use TI&#39;s cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...