Skip to main content
Graduate
October 21, 2024
Question

Windowmode of COMP1 and COMP2 gets disabled via COMP3

  • October 21, 2024
  • 1 reply
  • 646 views

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. 

    This topic has been closed for replies.

    1 reply

    ST Employee
    October 21, 2024

    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