Skip to main content
Johanan1
Associate III
February 3, 2021
Question

I wonder why this creates HardFaultError rarely and randomly. Thanks

  • February 3, 2021
  • 2 replies
  • 1049 views

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

This topic has been closed for replies.

2 replies

Johanan1
Johanan1Author
Associate III
February 3, 2021

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