How to get real adc dac on bluepill

Generic boards that are not Maple or Maple mini clones, and don't contain the additional USB reset hardware
Post Reply
triple_m
Posts: 3
Joined: Wed Dec 05, 2018 7:45 am

How to get real adc dac on bluepill

Post by triple_m » Wed Dec 05, 2018 9:56 pm

Bluepill should allow us to 12bit DAC, ADC in a material form (beyond simple PWM) according to the specification.
How do I use this functionality properly?

I tried to connect things to PA0 and PA1 and just read and write to them analog with the following code:

Code: Select all

unsigned int sample = 0;
 void setup() 
  {
     // define that i used pa0 as output pin
     pinMode(0, OUTPUT);
     Serial.begin(9600);
  }
  void loop()
  {
    // read analog data converted to digital (adc)  - i get 12 bit resulution here but cand use analogReadResolution/analogWriteResolution
    sample = analogRead(1);  // 1 == pa1
    // print to serial the digital data i got
    Serial.print(sample);
    // write digital to analog data (dac) - i can get only 8 bit resulution here (analogWrite writes 255 max)
    analogWrite(0 , sample );  // 0 == pa0
  }

And the result was particularly miserable ...
Can you direct me to a good code of analog reading and writing using analog to digital conversions and vice versa?

edogaldo
Posts: 432
Joined: Fri Jun 03, 2016 8:19 am

Re: How to get real adc dac on bluepill

Post by edogaldo » Wed Dec 05, 2018 10:33 pm

According to the specs, the blue pill does not have DAC, only ADC.
DAC is only supported on the bigger versions (the so said high density and xl density versions)

User avatar
mrburnette
Posts: 3001
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: How to get real adc dac on bluepill

Post by mrburnette » Wed Dec 05, 2018 10:39 pm

The best analog example is IMO:
http://stm32duinoforum.com/forum/viewtopic.php?t=107

As stated previously, the Blue Pill does NOT have a DAC internal.

PWM to analog is a subject outside this post. I suggest you start here:

https://www.google.com/search?q=arduino ... to+voltage

Good luck,

Ray

Post Reply