Anyone able to see why this goes wrong? Platform is Mega2560.
My attempt to use unsigned long as byte container to use as an index fails similar as if there is a problem with signet bit for uint16_t.
uint8_t keybitmap; uint32_t keyindex = 0; ..fill keybitmap with confirmed valid unsigned numbers 1,2,4,8,16,32,64,128 //uint32_t as 4 byte container keyindex |= keybitmap << 24; keyindex |= keybitmap << 16; keyindex |= keybitmap << 8; keyindex |= keybitmap;
Fails at bit 16
Serial.print("0x"); Serial.println(keyindex,HEX); //output from loop moving single bit though each byte fails at bit 16: 0x1 0x2 0x4 0x8 0x10 0x20 0x40 0x80 0x100 0x200 0x400 0x800 0x1000 0x2000 0x4000 0xFFFF8000 0x0 from here on