cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L476 OPAMP is not working as expected

Stm325
Associate III

Hi,I am using an STM32L476 on Nucleo64 board, I am amplifying a 1MHz 200mVpp sine wave with a 100mV offset in order to try the OPAMP but I dont think it is working. 

I configured OPAMP in PGA not connected mode(Also tried PGA connected too) and gave it to the same channel with my dual ADCs in order to read it from ADC. Before that I wanted to be sure that the amplified signal is correct but it is not. 

My Opamp configurations: 

static void MX_OPAMP2_Init(void) { /* USER CODE BEGIN OPAMP2_Init 0 */ /* USER CODE END OPAMP2_Init 0 */ /* USER CODE BEGIN OPAMP2_Init 1 */ /* USER CODE END OPAMP2_Init 1 */ hopamp2.Instance = OPAMP2; hopamp2.Init.PowerSupplyRange = OPAMP_POWERSUPPLY_LOW; hopamp2.Init.Mode = OPAMP_PGA_MODE; hopamp2.Init.NonInvertingInput = OPAMP_NONINVERTINGINPUT_IO0; hopamp2.Init.InvertingInput = OPAMP_INVERTINGINPUT_CONNECT_NO; hopamp2.Init.PgaGain = OPAMP_PGA_GAIN_4; hopamp2.Init.PowerMode = OPAMP_POWERMODE_NORMALPOWER; hopamp2.Init.UserTrimming = OPAMP_TRIMMING_USER; hopamp2.Init.TrimmingValueP = 0; hopamp2.Init.TrimmingValueN = 0; if (HAL_OPAMP_Init(&hopamp2) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN OPAMP2_Init 2 */ /* USER CODE END OPAMP2_Init 2 */ }

Stm325_0-1742476994977.png

Stm325_1-1742477009544.png

 

I gave my sine wave to PA6 and reading the output signal(Which is also the signal going to ADCs) from PB0. This is the output I get: 

 

PGA2_CON.PNG

 Yellow one is the input signal and green one is the output signal. It is reduced, offsetted and shifted. This is with gain 2. When I make gain 4 the signal just offsets more. I read the application note and datasheet too but could not figure out what am I doing wrong, I also started the OPAMP using HAL_OPAMP_START.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Stm325
Associate III

I figured that it the amplfying performance reduces as the frequency goes up so It is insufficient for high frequency signals, It is not working properly when the signal is higher than 400kHz, even with that it has an offset and phase shift so it is not usable after 50kHz in my experience.

I am not sure if there is any other internal mechanisms to increase its performance.

View solution in original post

2 REPLIES 2
Stm325
Associate III

Merged thread: same subject.

Hi, I am trying to sample a low voltage signal around -100mV to 100mV. I am able to sample it with dual interleave mode of ADC giving it a 120mV DC offset with a DC supply to be able to measure the whole signal. Now I want to give an offset first and then amplify the signal right before ADC. I read that STM32L476 OPAMPs can be used for both offsetting and amplification. I enabled IN15 as OPAMP2 Output Single-Ended for both ADC1 and ADC2 and selected "Dual Interleaved Mode Only".  I am kind of confused about configurations,

I am not sure how to configure OPAMP2, I need 2 things, one is to offset the signal for like 200mV(To shift it completely to positive side) and other is to amplify it. I understand that I should be able to do both from what is written in this document: https://www.st.com/resource/en/product_training/STM32L4_Analog_Opamp.pdf

Stm325_2-1742410285150.png

 

Stm325_3-1742410285210.png

 

I am not sure if I can set this with PGA not connected, also PB0 is for sampling the amplified signals but I am not sure what PA6 is for, I will not be amplifying my signal shifting it more than 1V so I think I also should be able to do it without giving an external bias. 

 

I have looked through some application notes but could not exactly figure out how to set these for my needs so I appreciate any advice. 

Stm325
Associate III

I figured that it the amplfying performance reduces as the frequency goes up so It is insufficient for high frequency signals, It is not working properly when the signal is higher than 400kHz, even with that it has an offset and phase shift so it is not usable after 50kHz in my experience.

I am not sure if there is any other internal mechanisms to increase its performance.