cancel
Showing results for 
Search instead for 
Did you mean: 

I wonder why this creates HardFaultError rarely and randomly. Thanks

Johanan1
Associate II

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];

2 REPLIES 2

Of course. Thanks a lot. I am kicking myself.:sad_but_relieved_face: