ChibiOS / ChibiOS-Contrib

Community contributed code (ports, drivers, etc).
130 stars 226 forks source link

[STM32F37x] Using two comparators simultaneously bug #363

Closed integernick closed 2 months ago

integernick commented 1 year ago

I've recently run into a bug while trying to use both of the analog comparators on STM32F37. The problem seems to be that on STM32F37 and STM32F38 COMP1 and COMP2 share the same 32-bit register COMP_CSR, so configuring the second comparator affects the configuration of the first one.

Here's an example:

image image Breakpoint 1: COMP1 configured.

image Breakpoint 3: Enabling COMP2 discards the COMP1 configuration.

I was able to fix this by adding some preprocessor directives to the os/hal/ports/STM32/LLD/COMPv1/hal_comp_lld.c, will create a pull request later.

ChibiOS version: stable_20.3.x Compiler: arm-none-eabi-gcc (10.3-2021.10) Platform and board: STM32F373CC (custom board)