Skip to main content
MNapi
Senior II
January 27, 2019
Question

how to declare byte in STM32

  • January 27, 2019
  • 2 replies
  • 2018 views

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 ?

    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    January 27, 2019

    // 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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    S.Ma
    Principal
    January 27, 2019

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

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