[SOLVED] analogWrite not working on DAC Pins on NUCLEO G071RB

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
phil_o_matic
Posts: 4
Joined: Mon Jul 27, 2020 5:24 am

[SOLVED] analogWrite not working on DAC Pins on NUCLEO G071RB

Post by phil_o_matic »

I’m running into issues with the DACs on my NUCLEO-G071RB.
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);
}
tested with and without analogWriteResolution
Last edited by phil_o_matic on Mon Jul 27, 2020 12:24 pm, edited 1 time in total.
phil_o_matic
Posts: 4
Joined: Mon Jul 27, 2020 5:24 am

Re: analogWrite not working on DAC Pins on NUCLEO G071RB

Post by phil_o_matic »

Thanks for that hint. I created an buildopt.h and added the -DHAL_DAC_MODULE_ENABLED line.

Sadly I don't get any output from the DAC
phil_o_matic
Posts: 4
Joined: Mon Jul 27, 2020 5:24 am

Re: [SOLVED] analogWrite not working on DAC Pins on NUCLEO G071RB

Post by phil_o_matic »

Update:
I tried running the DAC with the STM32CubeIDE. The DAC_DataOut Registers had the correct value without any voltage at the output.
Got really frustradet. Had a break and an idea.

The Nucleo I used was used by a colleage before who desoldered the juper for the reference voltage and Vref was therefore at 0V... I thought it was a brand new board and therefore didn't even think about that.

On the other hand it works just fine by now. Thanks for your help!
Post Reply

Return to “General discussion”