Zubax babel schematic and hardware init for libcanard

I am trying to run libcanard on the zubax babel board.
I couldn’t find a schematic anywhere to show what the crystal is and pin connections to the stm32.
I am trying to use cubemx to set up a project so I need to know what the xtal frequency is and pins connceted. I also need to know what the HSE_VALUE define refers to? Is it External crystal frequency or is it the system clock, or pll clk frequency?


Greetings! Please find babel schemaitc attached to this post
babel.pdf (58.2 KB)
HSE_VALUE is indeed frequency of the external crystal. System clock is obtained from it using PLL with its prescalers and dividers. UAVCAN may work with different system clock settings, it just has to know these settings. For that there is a function canardSTM32ComputeCANTimings.

Thanks, I did manage to create a startup project and got it to build and run, but it did not work. It got stuck in a tx function somewhere.
Is there any chance i can get the original .ioc (cubemx ) file used to generate the project?
I’m using SW4STM(ac6) not ewarm that appears was used in the sample code.
There is something wrong. Most code should be the same but the startup (.s) file is not.
I couldn’t see one there that was for sw4stm that would build on it, so I need to generate from cubemx.
Having the original cubemx file would help greatly in narrowing down what the problem is.
It might help to see where there are differences in generated source.


I’m sorry but there is no *.ioc file for this project as iCubeMX was not used to generate any code here.
Stm32CubeMX is well known for the low quality code it generates so I try to avoid it if I can.
If you’d like to use any kind of library for hardware init, I’d recommend you go on with SPL.
Also, do you have step by step debug available? It would be useful to know on what step exactly everything stops.
Best regards, Alex

I’m back on this again after a break.
I created another project in ac6 with SPL drivers, then copied over the drivers from the zubax source, and left cmsis from the created project. The startup file calls SystemInit from “system_stm32f37x.c” supplied in the source. hwInit is called from the supplied main.h, then swInit. The can timings computed are bit_rate_prescalar = 2, bit_segment_1 = 7, bit_segment_2=1,max_rescynchronization_width=1.
It does not transmit or recive anyhting.
When attempting to transmit it gets stuck in sendCanard() while (txf) loop.
canardSTM32Transmit() always returns 0 , meaning it didn;t transmit anything and keep it stuck in the while loop.
For first call we get result 1, then after always 0 for canardSTM32Transmit
Inside the function tme[3] = false,true,true
isFramePriorityHigher returns 0 and then the function exits wuth return code 0.
There is a mailbox whose priority is higher or equal priority of the new frame.
This is always returned.
I have a zubax babel connected to the other end running uavcangui which of course doesn’t show any messages incoming. I have checked the termination resistor is on for the uavcan gui babel device.
Is there anymore info on how to get this project to run?
Any clues or more debug required to find the problem?


Hi ,
I’m still at a loss to get this going after a lof of effort.
Can anyone help to get this project running?
I thought this should be relatively easy, but it just won’t work.
Is there any other things to try or test to find the problem?
The only thing I am doing differently is using SW4STM.
I am not sure what else I can try to get this to work.
I tried disabling sendCanard, so it doesn’t get stuck in a loop, but still nothing is recieved.
Please Help!!

Hi Kent Martin! Sorry for the delay.
Let me try to help you. Can you please describe your setup a bit more detailed? How many UAVCAN devices do you have on the bus and what are these devices? Could you also share your source code? I may want to reproduce your issues precisely.
Best regards, Alex

Hi, Thanks you can see the source here for 2 projects I did on the babel.

I have 2 zubax babels connected to each other. One with uavcangui running at 1Mbps , the other running the code in the link.

I now have made a standard CAN setup using cubemx and I can see messages coming out.
It’s not uavcan but I can at least get the hardware to do something. Although after the 1st transmit it fails as no one is responding to it I presume, and you have to stop it and restart it before sending another packet. I’ll try put libcanard on top of this and see if it can work then.


Hi Kent. I am facing same problem with this. Are you able to over come this problem. when i am debugging i came to know once the spincanard happens next time the return inside sendcanard will go into while loop tx_ref will always be zero. If any one can help please looking forward.

I’m not sure what problem you have but I have noticed that if the can bus is not powered the code will not start. You can fix this by changing some code so it will ignore this failure and the bus will work once power is applied. See the code below where I have commented out the error return when the inak does not occur after initialization. Ignore the extra code I put in to use interrupts, that is not necessary for it to work.

     * Hardware initialization (the hardware has already confirmed initialization mode, see above)

    BXCAN->BTR = (((timings->max_resynchronization_jump_width - 1) &    3U) << 24) |
                 (((timings->bit_segment_1 - 1)                    &   15U) << 16) |
                 (((timings->bit_segment_2 - 1)                    &    7U) << 20) |
                 ((timings->bit_rate_prescaler - 1)                & 1023U) |
                 ((iface_mode == CanardSTM32IfaceModeSilent) ? CANARD_STM32_CAN_BTR_SILM : 0);
    CANARD_ASSERT(0 == BXCAN->IER);             // Making sure the iterrupts are indeed disabled
    BXCAN->MCR &= ~CANARD_STM32_CAN_MCR_INRQ;   // Leave init mode
    if (!waitMSRINAKBitStateChange(BXCAN, false))
1 Like

I figured out the problem. The software waits for the ACK from the other device side which is to notify the message being received. Thank you for replying for the message.