When writing to a DAC1/1 on pin PA_4 on a NUCLEO L432KC using a for loop that incrementally increases the percent of the Vref to be outputted, the DAC output is seemingly left floating as the voltage output jumps around (observed with multimeter).
However, this same code works when using the online compiler and also works when there is no for loop. When I simply write a float value to the DAC (with no for loop) the DAC outputs the expected voltage.
NUCLEO_L432KC
arm-none-eabi-g++ 6.3.1 20170620 (release)
GCC_ARM
mbed-os-5.15.3
mbed-cli 1.10.2
VSCode 1.45.1
GNU bash (Git Bash), version 4.4.23(1)-release (x86_64-pc-msys)
I create a new Mbed project using mbed-cli with:
mbed new testProj
I set default toolchain with:
mbed toolchain GCC_ARM
I set default target with:
mbed target NUCLEO_L432KC
I make a main.cpp with the following code:
#include "mbed.h"
int main()
{
AnalogOut control(PA_4);
Serial pc(USBTX, USBRX, 9600);
while (1)
{
for (float i = 0; i < 1.0f; i += 0.01f)
{
control.write(i);
pc.printf("DAC Float Val: %f\n", i);
wait(5);
}
}
}
I compile in terminal with:
mbed compile -v -f
Nucleo board is flashed and the for loop is running since it's printing out to Serial. However, when observing PA_4 (A3) with a multimeter, it outputs ~0.9V and jumps around instead of slowly increasing.
However, this same code works when using the online compiler. Further, the following works just fine when using mbed-cli:
#include "mbed.h"
int main()
{
AnalogOut control(PA_4);
Serial pc(USBTX, USBRX, 9600);
while (1)
{
control.write(.3);
}
}
Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers.
Internal Jira reference: https://jira.arm.com/browse/MBOTRIAGE-2679
Thx @davidantaki for issue report.
I think I understand the issue now!
@0xc0170
you could set device st label
Thanks for the info/fix, much appreciated. @jeromecoutant
Most helpful comment
Thx @davidantaki for issue report.
I think I understand the issue now!
@0xc0170
you could set device st label