cancel
Showing results for 
Search instead for 
Did you mean: 

how to declare byte in STM32

MNapi
Senior III

I am using in adruino declaration

uint16_t x;

.

.

.

byte lowerByte = lowByte(x);

 byte upperByte = highByte(x);

Wire.beginTransmission(0x23); //Slave Address

 Wire.write(lowerByte);

 Wire.write(upperByte);

 Wire.endTransmission();

to send bigger numbers over I2C and it works fine

when I use byte to declare number in Keil it does not recognize it .

is there anyway to make the same in Keil ?

2 REPLIES 2

// overly verbose, but the compiler will optimize out

uint8_t lowerByte = (uint8_t)((x >>0) & 0xFF);

uint8_t upperByte = (uint8_t)((x >>8) & 0xFF);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal

check the definition of byte, lowByte() and highByte() which is not shown here.

Then you can check if there are any compiler dependent issues.