Page 1 of 1

analogWrite issues stm32vldiscovery via DAC

Posted: Fri Jul 14, 2017 7:20 pm
by Rick Kimball
I'm trying out the DISCO_F100RB from the pull request https://github.com/fpistm/Arduino_Core_ ... erge_Other.

The range of the values doesn't seem to match the VCC voltage.

Measuring the "3.3v" pin on the boards shows a reading of 2.99V

analogWrite(9,0); results in a 59mV reading on PA4.
analogWrite(9,255) results in 2.95V reading on PA4.
analogWrite(9,127) results in 1.49V reading on PA4.
analogWrite(9,63) results in 737mV reading on PA4.

Shouldn't a value of 255 produce the full range of 2.99 and a value of 0 produce a 0 V? The 127 and 63 value seems to be right.

What is the expected behavior?

Re: analogWrite issues stm32vldiscovery via DAC

Posted: Mon Jul 17, 2017 10:42 am
by Wi6Labs
Rick,

It seems your values are good to regards of the datasheet.

DAC ouput range:
  • min = 0.2V
  • max = VDDA - 0.2
So I think you couldn't have better values.

Re: analogWrite issues stm32vldiscovery via DAC

Posted: Mon Jul 17, 2017 11:59 am
by Pito
With DiscoVL you have got there an onchip 12bits dual DAC!
So you do not use analogWrite() [PWM based poor's man DAC], but you shoot 12bit numbers into the 12 bit DAC :)
Long time back I did measurements and you get the values from zero to almost Vdd (not sure I had DAC buffer on).

Re: analogWrite issues stm32vldiscovery via DAC

Posted: Mon Jul 17, 2017 12:30 pm
by Rick Kimball
The analogWrite() in the official STM core (see link in first post) uses the DAC peripheral if the pin is capable and falls back to PWM if not. I was using PA4 which is DAC CHANNEL 1.

Re: analogWrite issues stm32vldiscovery via DAC

Posted: Mon Jul 17, 2017 2:44 pm
by Rick Kimball
Wi6Labs wrote:
Mon Jul 17, 2017 10:42 am
Rick,

It seems your values are good to regards of the datasheet.

DAC ouput range:
  • min = 0.2V
  • max = VDDA - 0.2
So I think you couldn't have better values.
Thanks I was reading another document (AN3126) which gave this formula:
DACOutput = VREF x DOR / 4096

Which on some level made no sense as you can only use 0-4095 as values. However it didn't mention the electrical limitations from the data sheet