According to the STM32Duino API documentation https://github.com/stm32duino/wiki/wiki ... nalogWrite command on Pins PA4 and PA5 (DAC outputs) should result in an analog voltage at the pin driven by the internal DAC.
I tried the Arduino fade example replacing the D13 pin declaration with either PA4 or PA5 but only get a constant 0V at the Pins (LED jumper desoldered).
One possibility would be a missing HAL_DAC_MODULE_ENABLED definition for the STM32G071RB. Is this possible and how do I check this?
Thanks!
Phil
tested code:
Code: Select all
//original source: http://www.arduino.cc/en/Tutorial/Fade
int OutPin = PA5;
int brightness = 0;
int fadeAmount = 5;
void setup() {
analogWriteResolution(12);
pinMode(OutPin, OUTPUT);
}
void loop() {
analogWrite(OutPin, brightness);
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 4095) {
fadeAmount = -fadeAmount;
}
delay(1);
}