Hello,
I try to build 32bit value given by putting together 4 bytes: 0x18,0xE7,(uint8_t)c, (uint8_t)~c
What is wrong? I got: 18E68877, expected: 18E78877
// this function prints wrong value
static void put_ir_code_1( uint8_t c)
{
uint32_t nn;
nn = 0x18E70000;
nn += ((c) << 8);
nn += (uint8_t)(~c); // lsb
Serial.println(nn, HEX); // RS232 returns: 18E68877, expected: 18E78877
}
// this function returns proper value
static void put_ir_code_2( uint8_t c)
{
uint32_t nn;
nn = 0x18E78877;
Serial.println(nn, HEX); // RS232 returns: 18E78877
}
void setup() {
uint8_t i;
Serial.begin(9600); // send and receive at 9600 baud
i = 0x88;
put_ir_code_1(i);
put_ir_code_2(i);
}
void loop() {
// put your main code here, to run repeatedly:
}