Nucleo STM32F303RE, FREERTOS node.start freeze

Hi everybody,

I’m attempting to develop a UAVCAN subscriber node while using an STM Nucleo board and RTOS. I’m using the Nucleo STM32F303RE.

I have followed the examples in this repo: https://github.com/raimapo/UAVCAN-examples which I find to be very simple and easy to understand. I’m using the exact same files as the author is as a library.

I have defined the chip.h file manually (as I’m using the latest cubeMx auto-configuration and it is not generated by default)
It goes like this:

chip.h file

#ifndef CHIP_UAVCAN_CONFIG_H
#define CHIP_UAVCAN_CONFIG_H

#include <stm32f3xx.h>

#define STM32F3XX 

#define CAN1_TX_IRQHandler CAN_TX_IRQHandler // was CAN1_TX_IRQHandler in example
#define CAN1_RX0_IRQHandler CAN_RX0_IRQHandler // was CAN1_RX0_IRQHandler in example
#define CAN1_RX1_IRQHandler CAN_RX1_IRQHandler // was CAN1_RX1_IRQHandler in example

#define STM32_PCLK1 (36000000ul) // was 42000000ul in example
#define STM32_TIMCLK1 (72000000ul) // was 84000000ul in example

#endif

Also, I have defined these variables:

UAVCAN_CPP_VERSION=UAVCAN_CPP11
UAVCAN_STM32_FREERTOS=1
UAVCAN_STM32_TIMER_NUMBER=2
UAVCAN_STM32_NUM_IFACES=1

Lastly, the only difference with the shown examples are the GPIO CAN configs, like this:

	//CAN1 GPIO Configuration
	//PB8 , d15    ------> CAN1_RX
	//PB9 , d14    ------> CAN1_TX
    GPIO_InitTypeDef GPIO_InitStruct = {0};

	__HAL_RCC_CAN1_CLK_ENABLE();

	GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_9;
	GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
	GPIO_InitStruct.Alternate = GPIO_MODE_AF_PP;

	HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

When in the task, on the node.start() the whole system freezes…
I have checked this topic as well here.

Is there anything I am missing?
Do I need to manually setup the Timer or does the code do it by itself?

Thank you, any information would be greatly appreciated, best regards!

Hi,

After I have removed stmcube CAN driver generation it solved me some problems. I just added few line to define used pins directly in the code.

Also please carefully check version of the UAVCAN v0 library, because I have needed to change a branch, because of some sort of bug at that time. At my github in the module subdirectory is working branch of the libuavcan.

Am I am using also with stm32f303 and FreeRTOS
https://github.com/raimapo/GMM_BIG_V2_Firmware

Now I am waiting of fully finished V1 to make a new examples for the stm32. But because of absolutelly different approach I think I will need Pavel’s or others small help :smiley: or maybe some day by visiting TalTech I visit Zubax :smiley:

1 Like

Thank you for your feedback.

I will definitely check your repository.

If I have any further development I will update this thread

I have found the problem.

It was GPIO configuration all the time, here is the corrected GPIO Init:

	//CAN1 GPIO Configuration
	//PB8 , d15    ------> CAN1_RX
	//PB9 , d14    ------> CAN1_TX
    GPIO_InitTypeDef GPIO_InitStruct = {0};

	__HAL_RCC_CAN1_CLK_ENABLE();

	GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_9;
	GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
	**GPIO_InitStruct.Alternate = GPIO_AF9_CAN;**

	HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

Special thanks to @raimondas for pointing me to his code. After the correction, it worked instantly

1 Like

Hello, Rui, can you share link with your project, please? I am also working with NUCLEO F303RE and I think about using FreeRTOS in my project. But currently I use UAVCAN V1 (specifically libcanard v2.0).