I have calculated TH1=0xA5,TL1=0xFE
by ultrasonic sensor on. I want to display it on a LCD (16*2) like A5FE
using an 8051 MCU. My problem is that I'm using an integer value for displaying on the LCD.
Now I want to create a variable a
which will contain the value 0xA5FE
, that is a=0xA5FE
. How can I combine the value of TH1 and TL1?
假设TH1,TL1是uint8_t
:
uint16_t a = ((uint16_t)TH1 << 8) | TL1;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.