Skip to main content
NGupt.2
Visitor II
July 6, 2021
Question

STM32F779NI CAN peripheral programming with STM32-MAT/TARGET Simulink blocks

  • July 6, 2021
  • 1 reply
  • 821 views

Hello, I want to use STM32-MAT/TARGET to generate code for STM32F779NI CAN peripheral in interrupt mode to receive message over CAN bus. CAN IT block is having option only for TX, Rx and ESR interrupt. There is no option on CAN IT block to configure Rx Interrupt for FIFO FULL, FIFO MESSAGE PENDING and FIFO OVERRUN event. I want to call a function only when FIFO is Full.

Can anybody help me over this?

This topic has been closed for replies.

1 reply

Javier1
Principal
July 7, 2021

First of all i have no idea of how to use simulink blocks to program stm32

Maybe you can modify the "Automatic "C" code generation for STM32 is based on STM32Cube HAL libraries." to your needs before compiling

with regular handtyped code i would check every RX interrupt for the FIFO state with functions like :

  • HAL_CAN_GetTxMailboxesFreeLevel()
  • HAL_CAN_IsTxMessagePending() or HAL_CAN_GetRxFifoFillLevel()

Or take a look at the callback functions! in your Drivers/STM32xxxHAL_Driver/ folder

/** @addtogroup CAN_Exported_Functions_Group5 Callback functions
 * @brief Callback functions
 * @{
 */
/* Callbacks functions ********************************************************/
 
void HAL_CAN_TxMailbox0CompleteCallback(CAN_HandleTypeDef *hcan);
void HAL_CAN_TxMailbox1CompleteCallback(CAN_HandleTypeDef *hcan);
void HAL_CAN_TxMailbox2CompleteCallback(CAN_HandleTypeDef *hcan);
void HAL_CAN_TxMailbox0AbortCallback(CAN_HandleTypeDef *hcan);
void HAL_CAN_TxMailbox1AbortCallback(CAN_HandleTypeDef *hcan);
void HAL_CAN_TxMailbox2AbortCallback(CAN_HandleTypeDef *hcan);
void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan);
void HAL_CAN_RxFifo0FullCallback(CAN_HandleTypeDef *hcan);
void HAL_CAN_RxFifo1MsgPendingCallback(CAN_HandleTypeDef *hcan);
void HAL_CAN_RxFifo1FullCallback(CAN_HandleTypeDef *hcan);
void HAL_CAN_SleepCallback(CAN_HandleTypeDef *hcan);
void HAL_CAN_WakeUpFromRxMsgCallback(CAN_HandleTypeDef *hcan);
void HAL_CAN_ErrorCallback(CAN_HandleTypeDef *hcan);
 
/**
 * @}
 */

hit me up in https://www.linkedin.com/in/javiermuñoz/