stm32-rs / fdcan

FDCAN peripheral driver for STM32 chips
Apache License 2.0
12 stars 14 forks source link

On STM32G4 ILE bits are switched #4

Closed luctius closed 1 year ago

luctius commented 2 years ago

I just noticed that on the stm32g4, the meanings of the ILE bits are switched. This is (by the reading of the reference manual) not the case on the H7.

fdcan_ile

(Read the fine print, RM0440 Rev 6)

richardeoin commented 2 years ago

That's really confusing. Have you been able to check this functionality on real stm32g4 hardware? I suppose its possible either the high-level (EINT1/EINT0) or detailed description (fdcan_intr0_it/fdcan_intr1_it) is correct

luctius commented 2 years ago

Apologies for not being clear; I only found this after running into this issue with our hardware.

richardeoin commented 2 years ago

Should be fixed in #12

ho-ho-ho commented 1 year ago

Have you been able to check this functionality on real stm32g4 hardware?

Well, to add to the confusion: I just started writing code for a STM32G431CB, in the reference manual the lines are still swapped, but:

So it would appear that the manual was a typo (or a bug in the hardware?) and they may have fixed it in the meantime.

projectgus commented 2 months ago

I ran into this as well on STM32G474, and I think I have gotten to the bottom of it:

As per @ho-ho-ho's comment, ILE EINT0 and EINT1 bits are not switched on STM32G4. i.e. EINT0==bit 0, EINT1==bit 1. The per-bit-value descriptions in the SVD file and the Reference Manual are wrong, but the per-bit descriptions and bit names in these places are correct. ST's HAL driver agrees with this, too.

In the stm32g4 device support crate until last month (and in the current release), the interrupt numbers for FDCAN_INTR0_IT and FDCAN_INTR1_IT were switched. See https://github.com/stm32-rs/stm32-rs/issues/456 They should be 21,22 but they are 22,21.

Therefore, currently on stm32g4:

I think the correct course of action is to revert #12, and then either use the pre-release device support crate or manually swap FDCAN_INTR0_IT and FDCAN_INTR1_IT when implementing interrupt handlers.