cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G474 Opamp: CubeMX always enables negative in "PGA Internally Connected" mode

Herm
Associate III

With the G4 Cube package version 1.1.0 I could configure OPAMPs as  "PGA Internally Connected" and only the positive Input is enabled. With version 1.3.0 also the negative input is enabled. OPAMPs where this is not possible due to pin conflicts are silently disabled.

My interpretation of the datasheet is that the old behavior is correct and it should be possible to use the OPAMP only with a positive input.

Version 1.1.0:

0693W000003QK3xQAG.png

Version 1.3.0:

0693W000003QK4HQAW.png

1 ACCEPTED SOLUTION

Accepted Solutions

Hello Herm,

It is possible to use OPAMP only with a positive input using STM32CubeMX latest version ( STM32G4 Cube package version 1.3.0) by selecting PGA Not Connected mode.

Regards,

Khouloud

View solution in original post

6 REPLIES 6

Hello Herm,

It is possible to use OPAMP only with a positive input using STM32CubeMX latest version ( STM32G4 Cube package version 1.3.0) by selecting PGA Not Connected mode.

Regards,

Khouloud

Scotty55
Associate II

That is correct but prevents the OPAMP from internal connection to an ADC input, which is the most useful mode. Check with Stm32CubeMX 6.1 and Stm32G4 1.3.0:

Configure OPAMP5 as PGA not connected, try to select VOPAMP5 channel for ADC5: Not possible, checkbox is grayed out.

best regards - Rüdiger Becker

helbo
Associate II

I have the exact same problem and would like to know if there is a solution for this.

To optain a opamp with pga mode, internaly connected and with nothing else than the VINP pin connected. The init code schould look like this. Please correct me if im wrong.

I tried so many configurations in CubeIDE, but it won't give me the following code.

static void MX_OPAMP4_Init(void)
{
 
  /* USER CODE BEGIN OPAMP4_Init 0 */
 
  /* USER CODE END OPAMP4_Init 0 */
 
  /* USER CODE BEGIN OPAMP4_Init 1 */
 
  /* USER CODE END OPAMP4_Init 1 */
  hopamp4.Instance = OPAMP4;
  hopamp4.Init.PowerMode = OPAMP_POWERMODE_NORMAL;
  hopamp4.Init.Mode = OPAMP_PGA_MODE;
  hopamp4.Init.NonInvertingInput = OPAMP_NONINVERTINGINPUT_IO2;
  hopamp4.Init.InternalOutput = ENABLE;
  hopamp4.Init.TimerControlledMuxmode = OPAMP_TIMERCONTROLLEDMUXMODE_DISABLE;
  hopamp4.Init.PgaConnect = OPAMP_PGA_CONNECT_INVERTINGINPUT_NO;
  hopamp4.Init.PgaGain = OPAMP_PGA_GAIN_64_OR_MINUS_63;
  hopamp4.Init.UserTrimming = OPAMP_TRIMMING_FACTORY;
  if (HAL_OPAMP_Init(&hopamp4) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN OPAMP4_Init 2 */
 
  /* USER CODE END OPAMP4_Init 2 */
 
}

That doesn't seem to work, at least with the STM32G431, FW_G4 V1.3.0, and CubeMX 6.1.1 (and earlier versions).

"PGA Not Connected" mode requires VOUT to be connected to a pin.

In "PGA Internally Connected" mode, I get the same issue described by Herm above.

Scotty55
Associate II

Are there any plans to repair the CubeMX system and to re-enable the configurations of STM32G4 firmware version 1.2.0? I tried version 1.3.0 and 1.4.0, and it still doesn't allow to configure an OPAMP as follows:

 hopamp5.Instance = OPAMP5;

 hopamp5.Init.PowerMode = OPAMP_POWERMODE_NORMAL;

 hopamp5.Init.Mode = OPAMP_PGA_MODE;

 hopamp5.Init.NonInvertingInput = OPAMP_NONINVERTINGINPUT_IO2;

 hopamp5.Init.InternalOutput = ENABLE;

 hopamp5.Init.TimerControlledMuxmode = OPAMP_TIMERCONTROLLEDMUXMODE_DISABLE;

 hopamp5.Init.PgaConnect = OPAMP_PGA_CONNECT_INVERTINGINPUT_NO;

 hopamp5.Init.PgaGain = OPAMP_PGA_GAIN_32_OR_MINUS_31;

 hopamp5.Init.UserTrimming = OPAMP_TRIMMING_FACTORY;

This was generated with CubeMX version 5.6.1 and STM32G4 firmware version 1.2.0. I am using this in an actual project and because of the bugs in 1.3.0 and 1.4.0 can't change to newer versions.

Aurelian Lazarut
Associate II

The "funny" thing is that it works for OPAMP1 but not for OPAMP2 3 4 (in version 1.4.0) - if you select PGA Internally Connected will connect the VINP externally (and not connect the VINM) but it works only for OPAMP1 for the rest OPAMP2 /3/4 will connect the VINM to the external pin. see the picture below

0693W00000D08iXQAR.png0693W00000D08d3QAB.png

I hope we get these things fixed because were carried from v1.1.0 in various shapes and forms.

Maybe (just a suggestion) having a combo box for selecting the OPAMP types is not such a great idea. Things are more clear if the top level choices are just "Not used" "Follower" and "PGA" and the pinout connection are parameters listed like you have the gain.

Basically splitting the IN+, IN- and OUT settings in separate combo boxes next to gain and other stuff.

Aurelian

PS - @Rüdiger Becker​  I just realized this was reported almost 1 year ago so I'm wondering if we are wasting out time reporting these issues, lets wait another year....