8 years, 11 months ago.

ADC In to DAC Out Nucleo 302FR8 334FR8 L152RE How to configure the DAC Out?

Hi,

Im Jesse. real new. Got a fair amount of hardware experience but this programming and MCU stuff is taking a while to stick. Struggling a little to grasp the basics here.

Like to make my Nucleo 302FR8 read an ADC/AnalogIn (PA_0 or whichever one really, doesn't matter much) and output it via the DAC (PA_4)

Done a ton of googling and searching... I get the Nucleo_read_analog_value: https://developer.mbed.org/teams/ST/code/Nucleo_read_analog_value/file/6d058686efbf/main.cpp

So AnalogIn will configure the pin for the Nucleos ADC (Is that right, or when it's being programmed like the Arduino is it implemented differently?)

Most of the stuff I can find on the DAC is a Sinewave out and I can't extrapolate how to configure a pin for the DAC out. The Appnotes and Datasheets are a little over my head and don't necessarily apply directly to the MBED implementation.

How can I get from :

include the mbed library with this snippet

#include "mbed.h"
 
AnalogIn analog_value(A0);
 
DigitalOut led(LED1);
 
int main() {
    float meas;
    
    printf("\nAnalogIn example\n");
    
    while(1) {
        meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
        meas = meas * 3300; // Change the value to be in the 0 to 3300 range
        printf("measure = %.0f mV\n", meas);
        if (meas > 2000) { // If the value is greater than 2V then switch the LED on
          led = 1;
        }
        else {
          led = 0;
        }
        wait(0.2); // 200 ms
    }
}

to having the read analog value output from DAC pin PA_4?

Thanks!

Be the first to answer this question.