Stm32f7 nucleo 144 Digital Analog Convert. The STM32 Nucleo–144 boards provide an affordable and flexible way for users to try out new concepts and build prototypes
Table of Contents
1. Configure Clock And DAC
2.Generation Source and edit code
In Src/main.c
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_DAC_Init();
HAL_DAC_Start(&hdac, DAC_CHANNEL_1);
HAL_DAC_Start(&hdac, DAC_CHANNEL_2);
float i=0.0;
while (1)
{
i+=1;
if(i>2047){
i=0;
}
HAL_DAC_SetValue(&hdac, DAC_CHANNEL_1, DAC_ALIGN_12B_R,(int)(2048*(1+sin(i/4095*4*3.14))));
HAL_DAC_SetValue(&hdac, DAC_CHANNEL_2, DAC_ALIGN_12B_R,(int)i*2);
HAL_Delay(1);
}
}