2017-01-09 02:41 AM
Hi,
I have found a bug for STM32L071xx series in using the comperators with vrefint in the actual Reference Manual V7.0 and the actual HAL STMCubeL0 V.1.7.0:
When selecting the the vrefint for the comperator minus input the comperator is not working as expected and triggers at random values.
In the Reference Manual is said (Page 325):Note: If VREFINT or a fraction of VREFINT (using the scaler) is selected, then EN_VREFINT
bit must be set in the SYSCFG_CFGR3 register (see
Section 9.2.3: Reference control
and status register (SYSCFG_CFGR3)
).
But the EN_VREFINT is not set by the HAL in the function HAL_COMP_Init.
Further in the Reference Manual (Page 235):
Note: It is forbidden to configure both EN_VREFINT and ULP to 1 if the device is in Stop
mode or in Sleep/Low-power sleep mode (refer to
Section 6.4.1: PWR power control
register (PWR_CR)
for a description of the ULP bit). If the device is not in low-power
mode, VREFINT is always enabled whatever the state of EN_VREFINT and ULP.
This is not correct. In my test the VREFINT is not enabled for the comperator when the MCU is in RUN Mode.
As a workaround I enabled the the EN_VREFINT bit manually with:
SET_BIT(SYSCFG->CFGR3, 1);
Now the comperator is working as expected with VREFINT as minus input (only tested COMP2).
Additionally the bit 29 in SYSCFG_CFGR3 is set to 1. But don't now what it means because the bit name is 'Res.'.Be aware that you reset the EN_VREFINT bit before entering stop mode otherwise the power consumption in stop mode is much higher. Setting the ULP bit in PWR_CR Register is not working for me. But it has to be set to get the a low power consumption in stop mode.
Please check this and confirm.Best regards,
Tobias Wedell
#vrefint #bug #reference-manual-error #hal-bug #stm32l0712018-01-09 07:17 AM
And what about the issue with the reference manual Tobias mentioned in the second part of his post?
JW
2018-01-09 08:39 AM
Hello
Waclawek.Jan
,There was in the reference manualRM0377 Rev 8 updated in Section 9.2.3: Reference control and status register (SYSCFG_CFGR3) and the firmware package will be fixed according the reference manual.
Best Regards
Imen
2018-01-09 08:54 AM
Hi Imen,
The text in In RM0377, Rev.8, for SYSCFG_CFG3.EN_VREFINT mentions only the COMP2 *scaler* (' VREFINT is always enabled whatever the state of EN_VREFINT and ULP. EN_VREFINT controls only COMP2 scaler.'); whereas, apparently, COMP2's *unscaled* VREFINT input won't work either, unless this bit is set.
Also, I'd suggest to add this signal to Figure 51. Comparator 1 and 2 block diagrams.
Jan