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.
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: GitHub - 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?
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.
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.
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:
under Running on stm32 you refer to a STM32 test application. Does this exists?
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?
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.
I am actually looking for two independent interfaces for PX4. I was looking at your code and trying to use CanInitHelper in order to separate the two interface and use each one in a different instance, but I am not sure if it is the best option. In your code is also described, that CanInitHelper has to be instantiated only once, does that mean I can not use it twice in order to start two instances with different interfaces?
You can’t use the stock driver at all then, because it does not support the use case you’re describing (as I said, it’s an extremely uncommon one). Write your own driver.