h7 CAN not available

Ok, then which repo should I follow to be kept update on the upcoming improvements ?

I’ll update this thread as soon as we have any news about this.


We got everything working for our project, so it is possible to use H7 with CAN, although it is not “smooth” as of yet.
Basically we are using the stock micropython form openmv with the changes from the PR from iabdalkader with a few changes.

  1. the filters seemed not to work for me. After some troubleshooting, I found out, that first all packages have to be rejected to then allow only those specified by the filter
    → we added this line to ports/stm32/fdcan.c:154 after HAL_FDCAN_Init
    HAL_FDCAN_ConfigGlobalFilter(&can_obj->fdcan, 3, 3, 0, 1);
  2. can.any always returns true, this is because ports/stm32/fdcan.c:540 both options return true.
    You can however work around it by using something like
    while True:
    can.recv(0, lst, timeout=1)
    except OsError:

can.recv only works with the list argument. not providing one results in an empty list being returned. Filling the list however works fine. Its not too bad, but weird.
→ do this
lst = [0, 0, 0, memoryview(buf)]
and give lst as second argument to can.recv

Filtering with range filters is totally sufficient for us because you can set multiple filters with them.
can.setfilter(0, 0, (0xe1, 0xe2)
can.setfilter(2, 0, (0xf1, 0xf2)
to get both 0xe1 and 0xf1 in FIFO 0.

When synchronizing to our can bus we found another issue when reading:
We had to set prescaler=16, sjw=1, bs1=8, bs2=3 in can.init although we expected prescaler=18 according to stm32 cube mx.
According to pyb.freq we would have calculated a frequency of 41, sjw=4, bs1=12, bs2=5
I am not too familiar with this issue, so I can’t give any more details.

oh and don’t forget to add fdcan.c to the Makefile in openmv/src.

Hope this is helpful

Oh and big shout out to iabdalkader for making it possible, that we completed our project on time. Thanks :slight_smile:

Wow thank you, this is very useful indeed. I just got our CAN shields and will be working on this next weekend and I’ll add these changes the code.

We had to set prescaler=16, sjw=1, bs1=8, bs2=3 in can.init although we expected prescaler=18 according to stm32 cube mx.

I’m guessing maybe the project is set to 400MHz (the H7 runs at 480MHz now).

Hi, CAN is now supported on the H7, and I fixed the timing, setfilter() and any() bugs. The next release will be out in a day or two.

This is great!

I am surprised I did not get a notification, luckily I saw that Damien closed the issue on the Micropython github repo.

This was a big gating item for me, and it appears that most other functionality has been working well with the H7, so this means I can prototype moving from a F7 to a H7 and double most of my capability (oddly for less money).

Yeah, I just updated the resources in the IDE so then you open the IDE the new firmware will be downloaded.

It’s a huge amount of work to release the whole IDE. So, just updating the resources is a lot easier.

That’s a great news !!! I will get a H7 cam asap and test it.

Thank you !