Hello Flow Code Community,
may some one could help me please. I´ll try to use the follwing MSB-LSB Bit swop with ESP32:
DATACRC = (DATACRC >> 7) & 1 | (DATACRC >> 5) & 2 | (DATACRC >> 3) & 4 | (DATACRC >> 1) & 8 | (DATACRC << 1) & 0x10 | (DATACRC << 3) & 0x20 | (DATACRC << 5) & 0x40 | (DATACRC << 7) & 0x80
Unfortunately with this calculation I can not compile to ESP32. With my PIC 18Fxxxx Controler I never had a compile problem with this calculation.
May somebody can teach me how to modify.
BR
Dirk
MSB-LSB Bit swop not working with ESP32 Compiler
-
dvcam99
- Posts: 98
- http://meble-kuchenne.info.pl
- Joined: Fri Dec 04, 2020 11:03 am
- Has thanked: 6 times
- Been thanked: 12 times
Re: MSB-LSB Bit swop not working with ESP32 Compiler
OK found the problem by my self. Missing brackets were the problem. Here ist the correct version:
DATACRC = ((DATACRC >> 7) & 0x01) |
((DATACRC >> 5) & 0x02) |
((DATACRC >> 3) & 0x04) |
((DATACRC >> 1) & 0x08) |
((DATACRC << 1) & 0x10) |
((DATACRC << 3) & 0x20) |
((DATACRC << 5) & 0x40) |
((DATACRC << 7) & 0x80);
DATACRC = ((DATACRC >> 7) & 0x01) |
((DATACRC >> 5) & 0x02) |
((DATACRC >> 3) & 0x04) |
((DATACRC >> 1) & 0x08) |
((DATACRC << 1) & 0x10) |
((DATACRC << 3) & 0x20) |
((DATACRC << 5) & 0x40) |
((DATACRC << 7) & 0x80);
Happy FC9, FC-8 and FC-6 professional user 
-
mnfisher
- Valued Contributor
- Posts: 1694
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 146 times
- Been thanked: 789 times
Re: MSB-LSB Bit swop not working with ESP32 Compiler
There are some interesting algorithms:
Depending on how often you need to reverse the bits of a byte 0 - the quickest technique is probably a lookup table rev[256]
Where :
rev[0] = 0
rev[1] = 0x80
rev[2] = 0x40
etc
Then to reverse a byte rev_byte = rev[byte].
See also Hacker's Delight (Henry S Warren Jr)
Martin
Depending on how often you need to reverse the bits of a byte 0 - the quickest technique is probably a lookup table rev[256]
Where :
rev[0] = 0
rev[1] = 0x80
rev[2] = 0x40
etc
Then to reverse a byte rev_byte = rev[byte].
See also Hacker's Delight (Henry S Warren Jr)
Martin