go_away

Author Topic: Bit shifting help!  (Read 846 times)

0 Members and 1 Guest are viewing this topic.

Offline Razor ConceptsTopic starter

  • Supreme Robot
  • *****
  • Posts: 1,856
  • Helpful? 53
Bit shifting help!
« on: September 19, 2009, 04:18:30 PM »
I have a 10 bit number, for example, 1100000101. I want to store it in 8-bit EEPROM so I split that number into the high set and low set.

High set:
0000000011
Low set:
0000000101

How do I combine these two 8 bit numbers into the original 1100000101?


Offline chelmi

  • Supreme Robot
  • *****
  • Posts: 496
  • Helpful? 15
Re: Bit shifting help!
« Reply #1 on: September 19, 2009, 04:58:50 PM »
I have a 10 bit number, for example, 1100000101. I want to store it in 8-bit EEPROM so I split that number into the high set and low set.

High set:
0000000011
Low set:
0000000101

How do I combine these two 8 bit numbers into the original 1100000101?


Code: [Select]
uint8_t msb = 0x03;
uint8_t lsb = 0x05;

uint16_t n = (msb << 8) | lsb;

 


Get Your Ad Here

data_list