Skip to main content
yalamanda dosakayala
Associate II
March 21, 2018
Question

FreeRTOS and CAN driver for STM32F767 Nucleo board

  • March 21, 2018
  • 4 replies
  • 2028 views
Posted on March 21, 2018 at 07:37

Hi STM community,

I have STM32F767 nucleo board, As per my project requirements I need FreeRTOS and CAN driver for this Nucleo board.

I have downloaded latest SDK1.11 , but I didn't found any such example projects.

Can any help me , is there any sample projects related to this board.

or if no sample project , Can anyone guide me how do I start implementing the FreeRTOS and CAN driver.

#nucleo-stm #can #stm32-f7 #freertos
This topic has been closed for replies.

4 replies

Richard Lowe
Senior II
March 21, 2018
Posted on March 21, 2018 at 08:27

When using an RTOS you need to think about the actions (inputs, outputs) that are taking place. CAN does a couple of things, receives and transmits. Therefore, you could specify 2 tasks, 1 for RX and the other for TX duties.

/**
 * @brief All reception of CAN messages are processed
 *
 * Process is ran when the CAN RX interrupt passes the CAN_RX_ISR_FLAG. This
 * represents at least a single packet on the FIFO. All mailboxes are processed
 * and queued to the proper handler.
 *
 * @param argument task arguments - none needed
 */
void can_rx_process( void const * argument )
{
 osEvent evt;
 uint8_t data[8];
 CAN_RxHeaderTypeDef rx_msg;
 HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO0_MSG_PENDING | CAN_IT_ERROR );
 for( ;; )
 {
 evt = osSignalWait( CAN_RX_ISR_FLAG | CAN_ERR_ISR_FLAG, WDT_MAX_WAIT_TIME );
 if( evt.value.signals & CAN_RX_ISR_FLAG )
....�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

This is a CAN RX task that waits for the interrupt coming from messages pending.

/**
 * @brief Transmission of all CAN messages originate from this task
 *
 * @param argument
 */
void can_tx_process( void const * argument )
{
 osEvent evt;
 CAN_TxHeaderTypeDef tx_msg;
 uint8_t msg_data[8];
 uint32_t mailbox;
 osTimerStart( heartbeat_timer, CAN_HEARTBEAT_DELAY );
 for( ;; )
 {
 evt = osMessageGet( can_tx_handle, WDT_MAX_WAIT_TIME );
 if( evt.status == osEventMessage )
 {
 message_t *msg = (message_t*) evt.value.p;
....�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

This is a task that waits for another task to send a `message_t` to it.

Yes there are some extras in there you don't need but the principles are the same. Both tasks wait for some work to perform. The RX task waits for the interrupt of messages pending, the TX task waits for another task to send it some message to send.

yalamanda dosakayala
Associate II
March 21, 2018
Posted on March 21, 2018 at 10:56

Hi

Lowe.Richard

, thank you for reply, But I need code for the CAN driver for STM32F767 Nucleo board.

Is there any sample project for the CAN driver for Nucleo board.

Please share me the link

Richard Lowe
Senior II
March 21, 2018
Posted on March 21, 2018 at 18:53

There really isn't any 'driver' for CAN on the STM32. It is a hardware peripheral, so it's all about configuring the peripheral to your purposes. Any of the CAN demos in the STM32 repos demonstrate this. If the STM32F767 has CAN then the `<STM32CubeInstallDir>/Repository/STM32Cube_FW_F7_V1.11.0/Projects/STM32F769I_EVAL/Examples/CAN/CAN_Networking` for example.