Windowmode of COMP1 and COMP2 gets disabled via COMP3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-10-21 6:30 AM
Hey community,
I am struggling with the setting of the window mode of the COMP1 and COMP2 comparators and a standalone COMP3 comparator of the STM32G0B1CET. The settings are done via the CubeMX .ioc file. The COMP1 gets its INPUT+ and the COMP2 is setup in Window Mode. Each INPUT- is setup via a DAC output. The COMP3 is setup with its own INPUT+ and INPUT- analog pins.
Now when the code gets auto generated, the resulting code in main.c is this:
/* ... */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_COMP1_Init();
MX_COMP2_Init();
MX_COMP3_Init();
/* ... */
/* Check bitfields */
uint32_t comp_cr = LL_COMP_ReadReg(COMP2, CSR);
/* Extract WINMODE */
uint32_t winmode_value = (comp_cr & COMP_CSR_WINMODE) >> COMP_CSR_WINMODE_Pos;
bool winmode_correct = winmode_value == 0b1;
The problem: After MX_COMP3_Init() finished, the Window Mode of COMP2 gets removed.
Solution: Change the order of MX_COMP2_Init(); and MX_COMP3_Init();
Is this a software bug from ST?
To be clear on the bitfield level:
MX_COMP2_Init sets the hcomp2.Init.WindowMode = COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON.
A check of hcomp2.Instance->CSR & COMP_CSR_WINMODE shows the respective bit is set to 1. Checking again after MX_COMP3_Init() finished, the COMP_CSR_WINMODE returns 0.
- Labels:
-
STM32CubeMX
-
STM32G0 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-10-21 8:51 AM
Hello @derLalla,
Thank you for bringing this issue to our attention.
I confirm this is a bug in the COMP HAL driver.
I reported it internally to be fixed by our development team.
Internal ticket number: 194520 (This is an internal tracking number and is not accessible or usable by customers).
Best regards
