I am trying get variables from UART packet without using "<<" operator.
uint8_t buffer[8] = {0x11,0x22,0x33,0x44};
uint16_t val = *((uint16_t *)buffer);
If I try the code above in keil it is working. When I try it for the array in struct compiler doesn't give error but it goes to hardfault handler during runtime.
typedef struct
{
uint8_t address;
uint8_t opID;
uint8_t dataLen;
uint8_t data[250];
uint8_t crc[2];
}MODBUS;
MODBUS receivedData;
uint16_t val = *((uint16_t *)receivedData.data);
I also tried this(array in struct) in online c compiler. It is working without any problem. What should I do to use same thing in keil?