int main(void)
{
u16 adcx;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置系统中断优先级分组2
delay_init(168); //初始化延时函数
uart_init(115200); //初始化串口波特率为115200
LED_Init(); //初始化LED
LCD_Init(); //LCD初始化
Adc_Init(); //adc初始化
Dac1_Init(); //DAC通道1初始化
POINT_COLOR=RED;
LCD_ShowString(30,50,200,16,16,"Explorer STM32F4");
LCD_ShowString(30,70,200,16,16,"DAC TEST");
LCD_ShowString(30,90,200,16,16,"ATOM@ALIENTEK");
LCD_ShowString(30,110,200,16,16,"2014/5/6");
LCD_ShowString(30,130,200,16,16,"WK_UP:+ KEY1:-");
POINT_COLOR=BLUE;//设置字体为蓝色
LCD_ShowString(30,150,200,16,16,"DAC VAL:");
LCD_ShowString(30,170,200,16,16,"DAC VOL:0.000V");
LCD_ShowString(30,190,200,16,16,"ADC VOL:0.000V");
while(1)
{
adcx=Get_Adc(ADC_Channel_5);
DAC_SetChannel1Data(DAC_Align_12b_R,adcx);//初始值为0
LED0=!LED0;
}
}
与stm32f407给的DAC代码除while 部分不一样之外,全都一致。此处需注意,系统频率应该是输入的波形的频率的10倍以上保证输出波形的完整性,系统的输出频率可以使用示波器测试出。示波器正极接LEDO的正极,负极接GND,显示的频率*2即为系统频率 |