STM32CubeMx DAC DMA output + display sine wave + ADC acquisition + SeriaPlot graphical serial port use (as an oscilloscope to see the waveform)

The principle is roughly, for example, there are many switches controlling a group of resistors, and we manipulate the switches to obtain the corresponding voltage value.

Ordinary DAC:

 

 

 

 

 

DMA DAC generates square wave:

 

 

 

 

 

 

 

 

 

Voltage conversion can directly input floating point 0-3.3V

void dac_send(float V)
{
	int Send_V;
	Send_V=(int)(V*4095/3.3);
	HAL_DAC_SetValue(&hdac,DAC_CHANNEL_1,DAC_ALIGN_12B_R,Send_V);
}

DMA adc dac function and normal DAC start function 

HAL_ADC_Start_DMA(&hadc1,(uint32_t*)adc_buff,1);
HAL_TIM_Base_Start(&htim6);
//HAL_DAC_Start(&hdac,DAC_CHANNEL_1);
HAL_DAC_Start_DMA(&hdac,DAC_CHANNEL_1,(uint32_t*)Sine12bit,100,DAC_ALIGN_12B_R);

Guess you like

Origin blog.csdn.net/weixin_63163242/article/details/132045693