I'm trying to make use of the bxCAN of STM32F103C8 on a bluepill but it doesn't work and I don't know what is the problem.I'm using the hal API
here is the main code in the while loop
while (1)
{
char msg[50];
CAN_TxHeaderTypeDef TxHeader;
uint8_t data[5] = {'H','E','L','L','O'};
uint32_t TxMailbox;
TxHeader.DLC = 5;
TxHeader.ExtId = 0x18181820;
TxHeader.IDE = CAN_ID_EXT;
TxHeader.RTR = CAN_RTR_DATA;
if(HAL_CAN_AddTxMessage(&hcan, &TxHeader, data,TxMailbox) != HAL_OK){
Error_Handler();
}
while(HAL_CAN_IsTxMessagePending(&hcan, TxMailbox));
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);
HAL_Delay(1000);
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);
HAL_Delay(1000);
}
The code breaks at the HAL_CAN_AddTxMessage.
this is my first time working with an STM32 so I've never had a working example and couldn't find any working examples online.
Please help I've posted many times :/