2018-10-22 02:10 AM
I setup a project in CubeMX (STM32F302C6), activated CAN (and other peripherals) and did everything. I generated the code and opened it in eclipse. However, in the HAL_CAN library the functions like HAL_CAN_Transmit are missing. I have these control functions:
/* Control functions **********************************************************/
HAL_StatusTypeDef HAL_CAN_Start(CAN_HandleTypeDef *hcan);
HAL_StatusTypeDef HAL_CAN_Stop(CAN_HandleTypeDef *hcan);
HAL_StatusTypeDef HAL_CAN_RequestSleep(CAN_HandleTypeDef *hcan);
HAL_StatusTypeDef HAL_CAN_WakeUp(CAN_HandleTypeDef *hcan);
uint32_t HAL_CAN_IsSleepActive(CAN_HandleTypeDef *hcan);
HAL_StatusTypeDef HAL_CAN_AddTxMessage(CAN_HandleTypeDef *hcan, CAN_TxHeaderTypeDef *pHeader, uint8_t aData[], uint32_t *pTxMailbox);
HAL_StatusTypeDef HAL_CAN_AbortTxRequest(CAN_HandleTypeDef *hcan, uint32_t TxMailboxes);
uint32_t HAL_CAN_GetTxMailboxesFreeLevel(CAN_HandleTypeDef *hcan);
uint32_t HAL_CAN_IsTxMessagePending(CAN_HandleTypeDef *hcan, uint32_t TxMailboxes);
uint32_t HAL_CAN_GetTxTimestamp(CAN_HandleTypeDef *hcan, uint32_t TxMailbox);
HAL_StatusTypeDef HAL_CAN_GetRxMessage(CAN_HandleTypeDef *hcan, uint32_t RxFifo, CAN_RxHeaderTypeDef *pHeader, uint8_t aData[]);
uint32_t HAL_CAN_GetRxFifoFillLevel(CAN_HandleTypeDef *hcan, uint32_t RxFifo);
But these are not even described in the documentation (https://www.st.com/content/ccc/resource/technical/document/programming_manual/6c/3a/cb/e7/e4/ea/44/9b/DM00046982.pdf/files/DM00046982.pdf/jcr:content/translations/en.DM00046982.pdf )
Probably I am missing some settings in CubeMX but I can't find them...
2018-10-23 06:57 AM
Hello @YFric ,
With the new HAL CAN driver, the function HAL_CAN_Transmit() is replaced by HAL_CAN_AddTxMessage() to place Txrequest, then HAL_CAN_GetTxMailboxesFreeLevel() for polling until completion.
As the HAL CAN driver has been redesigned with new API, please find below a short migration guide:
Please refer to the attached document for more details about the new HAL CAN driver and migration guide.
Kind Regards,
Imen
2018-11-03 12:52 AM
I don't have an answer to contribute but have a further question since I had the same question as the original poster. Is there a more-up-to-date documentation somewhere I can read so we don't need to constantly search the web for information? It's been very frustrating trying to get CAN to work on the STM32F4 because the documentation is outdated :( I appreciate any help!
2018-11-03 12:55 AM
@Imen DAHMEN Thank you, this helped indeed a lot!
@Hidekazu I haven't found anything except the manual linked above, it is indeed frustrating at times...
2019-02-26 05:06 AM
Hello Imen,
a small bug page 17 :
void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef* hcan)
{
HAL_CAN_GetRxMessage(&hcan1 => hcan ,CAN_RX_FIFO0,&RxHeader,RxData);
HAL_GPIO_TogglePin(GPIOB,GPIO_PIN_2);
}
regards
2020-02-04 02:14 PM
Is there a possibility of coercing someone into converting this random powerpoint into a proper app note describing the CAN system API?
Please?
Andrei
2022-05-27 03:18 PM
@Imen DAHMEN Sorry to necropost, but is there any update on this? It's pretty ridiculous that such a basic feature as transmitting a canbus message has documentation that is actively wrong - and for this to be the case for at least 3 years!