2021-02-03 05:02 AM
rxBuf is uint8_t array.
// this creats HardFault sometimes:
id = *(uint32_t *)&rxBuf[i];
//----------------------------------------------------
// but this works OK forever:
id = rxBuf[i + 3];
id <<= 8;
id += rxBuf[i + 2];
id <<= 8;
id += rxBuf[i + 1];
id <<= 8;
id += rxBuf[i + 0];
2021-02-03 05:12 AM
Because it can create unaligned memory access on a CPU (Cortex-M0), which doesn't support that.
2021-02-03 05:52 AM
Of course. Thanks a lot. I am kicking myself.