Problem with ADC

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
of2rs
Posts: 1
Joined: Tue Mar 10, 2020 11:09 am

Problem with ADC

Post by of2rs »

Hi everyone,

I'm making a project with a Bluepill (the cheap one that mounts a STM32103C8T6) where I was using the LibMaple adaptation for Arduino IDE. I had to know when does the micro reset by the iwatchdog. I wasn't able to know that because I think LibMaple doesn't have enable low level of programming.
Because of that, I decided to switch to the STM32duino adaptation (this one, I don't know its oficcial name: https://github.com/stm32duino/wiki/wiki), and now I can know when the reset by iwatchdog happens (thanks to de IWATCHDOG library).

The problem is that now the ADC on PA6 (used as an analog input) doesn't work correctly. The ADC's raw values just goes from 0 to ~815, instead of 0 from 4095 of the 12 bits. In addition, I'm using an humidity prove (DHT22 I think) and now it doesn't give me any value (may this is due to the library). I have tried disabling debug ports as I do with LibMaple, but I couldn't. I also tried remapping the SPI1, because MISO1 seems to be defined on PA6, but it didn't work (may I didn't do it right because I edited the wrong file). Using LibMaple, the project works correctly, so I suppose that it is a software problem that I can't handle.

I also want to know if I can solve the iwatchdog issue with the LibMaple. That would be awesome, because I'm really familiarized with LibMaple, and most of my projects doesn't need to go to low level programming.

Thankssss :D
User avatar
Pito
Posts: 94
Joined: Tue Dec 24, 2019 1:53 pm

Re: Problem with ADC

Post by Pito »

Pukao Hats Cleaning Services Ltd.
User avatar
fpiSTM
Posts: 1760
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Problem with ADC

Post by fpiSTM »

Hi,

by default ADC_RESOLUTION is 10 bits and not 12 bits in this core.
You can use analogReadResolution to change it.

I've just testest PA6 and get the proper value for 0 to 3.3V: 0 to 1023 for 10 bits resolutions and 0 to 4095 for 12 bits.

About DHT22, don't know which library you use so probably yes, it is linked to your library.
For SPI remapping, this is not needed if you don't use SPI.
Post Reply

Return to “General discussion”