2026-05-21 5:49 AM - last edited on 2026-05-21 6:57 AM by mƎALLEm
Hi All,
In my application, I am using the STM32L451RCT6 and trying to configure COMP2 with the internal Vref as a reference (specifically 3/4 Vref). For some reason, it never worked. I was only able to get it working when using DAC_CH1 or an external source as the reference. After a few days of troubleshooting and research, I finally found a relevant block diagram along with an important note in the reference manual (page 532).
The thing is, there are no mentions or explanations of this behavior in the reference manual, datasheet, or errata other than this. Could you confirm whether the STM32L45x series actually supports using the internal Vref as a comparator reference or am I facing some other issue here? Thank you!
2026-05-21 6:16 AM - edited 2026-05-21 6:18 AM
Hello,
If it was indicated by the reference manual especially the RM0394 / the note under the figure 118, no need to indicate the reason why this was not implemented nor to indicate it in the errata sheet.
Perhaps, it was a choice by the design to not implement the VERFINTxxx on L45xx and L46xx as COMP inputs.
2026-05-21 6:19 AM - edited 2026-05-21 6:50 AM
This is a nasty documentation fail... I believe it's a design bug disguised as documented feature, but documented extremely poorly.
Also in DS:
If DAC_CH2 is not connected, than that should be documented too.
JW
[EDIT] I've just noticed there's no 'L461; 'L45x/'L46x would be more appropriate; sorry.
[EDIT2] There's no DAC_CH2 in 'L45x/'L46x, that's documented properly in the DAC chapter and DS; should be mentioned in the INMSEL fields description, and the Fig.118 footnote should be formulated clearer.
[EDIT3]
Footnote to say unavailability of Vrefint and fractions, and DAC_CH2, should be added to Table 90. COMP1 input minus assignment and Table 92. COMP2 input minus assignment, too
Also, COMPx_CSR.SCALEN and COMPx_CSR.BRGEN appear to be linked to Vrefint and fractions. It would be nice if they would be depicted in Fig.118. The "bandgap" term should not be used in description of those bits, as this term is not explained/mentioned anywhere else in the RM (it is in the ADC chapter, where it may be confusing either). "Internal reference voltage", or "Vrefint" is used everywhere else.
2026-05-21 6:25 AM
Yes, I agree. It is really hard to believe that such an important limitation is mentioned only once and in such an unexpected place. Unfortunately, it affects my project a bit. I guess I will have to solder a wire to an external pin.
2026-05-21 6:26 AM - edited 2026-05-21 6:28 AM
@waclawek.jan wrote:
I believe it's a design bug disguised as documented feature.
I'm not in favor with this. We always document limitations in the errata.
But yes the documentation may have issues with some confusions / misleading text.
Will escalate for review and fix.
2026-05-21 6:55 AM
The case was internally escalated over this internal ticket CDM0062827 for follow-up.
2026-05-21 7:00 AM
Thank you for such a quick reaction! I really appreciate it.
2026-05-21 7:11 AM
I looked also at Cube (not CubeMX, I don't use it and don't intend to install/run/learn).
In stm32l4xx_hal_comp.c, there's a table listing the options for comparator inputs/outputs. It lists exceptions for 'L41x/'L42x and for 'L43x/'L44x, for which I can't find references in the COMP chapter in RM0394, and, sure, doesn't list the exceptions for 'L45x/'L46x. Haven't had look at the actual code, if it performs some actual validity checks in this regard.
In stm32l4xx_ll_comp.c, there's an actual check, which does not take into account the discussed 'L45x/'L46x exception.
(Just to explain my surge of activity here: I do use the 'L431 and 'L451 actively in a group of projects, and although not COMP so far, it may happen such requirement will come one day as we've expanded the scope already several times, and I don't want to be surprised either. Btw. these are chips with a really nice set of features, truly.)
JW