cancel
Showing results for 
Search instead for 
Did you mean: 

ADC after RST pin stm32

david lion
Associate II
Posted on June 06, 2017 at 17:38

Hi, I have a problem with the adc. I want to get

the voltage of the STM.

At the start up of my program I want to get the voltage of the STM. So I init the internal ADC and get VREFINT. I have the good value whit my calculation, so no problem there.

My problem is when I use the RST pin of the stm32. After rebooting the stm32 by using the RST PIN I read wrong value at the vrefint channel ( from 0 to 1500, or I used the oversampling mode so I must read value around  22700).

When I rebot the system electricaly, turn off and then turn on the power, the value is good. The problem is only when I used the RST pin.

Do you know where is the problem ? 

Thanks !

Sorry for my english ...

#adc #reset #stm32l
4 REPLIES 4
Zt Liu
Senior III
Posted on June 07, 2017 at 06:59

Hi, David,

VREFINT(regulated internally) is quit different from VDD or VDDA, right? So it may not be a good idea for using VREFINT to know VDD or VDDA.

As for the strange result after reset.....

I just use CubeMX and nucleo stm32F303 to make a quick check.

...

SystemClock_Config();

MX_GPIO_Init();

MX_USART2_UART_Init();

MX_ADC1_Init();

printf(''System Restart!\r\n'');

while (1)

{

   HAL_ADC_Start(&hadc1);

   HAL_ADC_PollForConversion(&hadc1, 20);

   adcResult = HAL_ADC_GetValue(&hadc1);

   printf(''VREFINT Value is %d\r\n'', adcResult);

  HAL_Delay(500);

}

It seems okay without the strange result you've described. (I use the onbard reset button.)

0690X00000602PSQAY.bmp

So there could be some problem in your reset mechanism...circuitry or something.

Good luck!

:(

david lion
Associate II
Posted on June 07, 2017 at 09:19

Thanks for your responses.

I use a stm32l0, and to reset the mcu I have a mechanism with a button where I need to push it 15 sec. The reset works.

I also noticed that when I flash my board with ST link, I have the same problem (the RST pin flag is set when I flash the board, so I supposed theRST pin is used by st link).

Next, I tried to make the conversion without the oversampling, and most of the time I get 2 in in the register of the ADC ... but when I electrically restart the STM, I have the same value as

Liu.Zhitai

.

Posted on June 07, 2017 at 08:23

... ( from 0 to 1500, or I used the oversampling mode so I must read value around  22700).

This makes me guess the OP was speaking about the 16-bit Sigma-Delta ADCs, of which the F303 has none.

It would be great if he (the OP) would be a bit more precise about his hardware and environment ...

Posted on June 07, 2017 at 09:59

with a button where I need to push it 15 sec.

To reset the mcu after a button has been pushed 15 sec. I would use external interrupt and timer to fulfill this detection and then called NVIC_SystemReset();

You may use oscilloscope to check your button circuitry and reset pin while you are pushing the button, perhaps you will discover something. Good Luck!