When assigning a pointer to structure pointer, mcu goes in to Hardfault Handler.
Hi Everyone,
When I send a structure pointer as an agument to a function, and trying to catch address of a variable in the structure in the function, MCU goes in to hardfault handler function. Let me simplify the problem as below,
uint8_t *ptr1;
uint32_t *ptr2;
uint32_t temp;
typedef struct{
uint8_t Data[10];
}example_struct;
example_struct sensor;
sensor.Data[0] = 0xAA;
ptr1 = &sensor.Data[0]; // here ptr1 is pointing 0xAA with no problem
ptr2 = (uint32_t*) ptr1; // here *ptr2 is 0x000000AA, so there is no problem.
temp = *ptr2; // here mcu goes in to hardfault handler
Do you have any idea why I am having this issue?
Thanks