STM32 HAL CAN does not update value and crashes when setting ExtId
By default STM32CubeMx create the initialization code for 'can' (if selected). This code can be found in MX_CAN_Init and is called by main.

However, it does not assign/initialize the pRxMsg and pTxMsg. 

The pTxMsg should be defined as:

CanTxMsgTypeDef txMessage;
hcan.pTxMsg = &amp;txMessage;


and the pRxMsg as:

CanRxMsgTypeDef rxMessage;
hcan.pRxMsg = &amp;rxMessage;