Getting hard fault when assigning this 32 bit value to the shown variable(val_32);
uint32_t val_32 = *((uint32_t *)( &buffer[0] + length - 4));
or
uint32_t val_32 = *((uint32_t *)( &buffer[length - 4] ));
Same thing but tried:
uint32_t val_32 = *((uint32_t *)(buffer + length - 4));
Declarations of the variables used;
uint8_t buffer[200];
uint8_t length;
System:
MCU = STM32F072C8T6
Keil v5.23
When i debugging, hardfault occurs at stepping over this code. Though without stepping over i put that code to the watch window and get the result i expected. Dont know what is my mistake or how to fix it. Thanks for the help.