Libcanard not working on stm32f4discovery


(Albert Martinez) #1

Hi,

I have 2 Babel boards. I wanted to follow the tutorial on knowledge base, but I am stuck on the first one…

I wanted to compile the code into a stm32f4discovery board, this has an external crystal HSE=8KHz. I used CAN 1 in port PD0 and PD1 (Rx,Tx). The code i compiling and I am able to load into the board , but It is not transmitting. Actually the code returns with CANARD_STM32_ERROR_UNSUPPORTED_BIT_RATE. Is this a timing issue? What else could it be?

Gui Tool and Babel are working find, as I tried to communicate with a Pixhawk 2.

Code is the same as in you basic example.

I will appreciate any help, as I would like to get libcanard running on the discovey before touching a babel hardware.

Sincerely,

Albert


(Pavel Kirienko) #2

Hi Albert,

Have you updated the HSE configuration in the source? What bit rate are you trying to use?


(Albert Martinez) #3

Hi Pavel,

thanks for the fast answer. I set it to HSE_VALUE=8000000. Taget_bitrate is set to 1000000, as in your example.
you can look here: https://github.com/kuiskas/libcanard_test
I also had problems under linux(System Workbench) with usleep(). That is why I am trying under windows (IAR). Is there any other function I can use in order to make a standard delay? Maybe with Systicks?

thanks in advance


(Pavel Kirienko) #4

You should determine which exact part of the CAN timing settings computation fails with that error. Put some breakpoints.

I also had problems under linux(System Workbench) with usleep(). That is why I am trying under windows (IAR). Is there any other function I can use in order to make a standard delay? Maybe with Systicks?

You should implement it yourself; yes, you can use the SysTick timer for that.


(Albert Martinez) #5

Thanks for the answer. At the end it was a timing issue, somehow the stm32f4 discovery did init at a wrong frequency.
I went trough your tutorial and now I would like to test some of the libuavcan functionalities before jumping into nuttx. Do you have any bare example somewhere in github which I could follow. This will be really usefull.


(Pavel Kirienko) #6

I think the best starting point are the official libuavcan tutorials: https://uavcan.org/Implementations/Libuavcan/Tutorials/

Libuavcan is a bit hard to set up initially, but once it builds, further development is a breeze.


(Albert Martinez) #7

Hi again Pavel,
well I’ve been reading the documentation you pointed at. I wasn’t able to setup the enviroment. Libuavcan theory can I understand, but I just find too complicated the setup for stm32 (system workbench) without any example.
In the tutorial:
https://uavcan.org/Implementations/Libuavcan/Tutorials/2._Node_initialization_and_startup/
under Running on stm32 you refer to a STM32 test application. Does this exists?


(Pavel Kirienko) #8

We used to have it, it got removed because at this point there are plenty of open source projects that leverage libuavcan on STM32. E.g. https://github.com/PX4/sapog or https://github.com/Zubax/zubax_gnss


(Albert Martinez) #9

Hi Pavel,
yes I saw the projects. I tought it would be good to get it running baremetal as I do not know how to use ChibiOS and Nuttx does not implement it anymore. Anyway I manage to use it with PX4 firmware.
Just one question. In case of 2 CAN buses, how could I chose which one I am sending to. Do I have to create 2 task or there is other easier workaround?


(Pavel Kirienko) #10

In case of 2 CAN buses, how could I chose which one I am sending to. Do I have to create 2 task or there is other easier workaround?

If you have more than one CAN interface, two configurations are possible:

  • Redundant transport configuration. In this case, you create only one CAN node, and it uses all available interfaces simultaneously. You don’t get to choose which one to use when – they are always used at the same time in the same manner. That’s the purpose of modular redundancy – if one interface fails anywhere on the bus, the whole redundant transport will continue functioning unaffected.
  • Two independent interfaces (this case is extremely rare and I am nearly certain this is not what you need). In this case, you create an independent node per interface, and handle each one separately. This architecture may be useful, for example, if you’re building a bridge between several different UAVCAN networks.