#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "key.h"
#include "usmart.h"
#include "adc.h"
#include "dac.h"
/************************************************
ALIENTEK 阿波罗STM32F429开发板实验21
DAC实验-HAL库函数版
************************************************/
int main(void)
{
u16 adcx;
float temp;
u16 dacval=0;
HAL_Init(); //初始化HAL库
Stm32_Clock_Init(360,25,2,8); //设置时钟,180Mhz
delay_init(180); //初始化延时函数
uart_init(115200); //初始化USART
usmart_dev.init(90); //初始化USMART
LED_Init(); //初始化LED
KEY_Init(); //初始化按键
DACx_Init(225,1);
MY_ADC_Init(); //初始化ADC1
printf("DAC TEST\r\n");
printf("DAC VAL:\r\n");
printf("DAC VOL:0.000V\r\n");
printf("ADC VOL:0.000V\r\n");
while(1)
{
LED0=!LED0;
delay_ms(500);
//HAL_DAC_SetValue(&DAC1_Handler,DAC_CHANNEL_1,DAC_ALIGN_12B_R,dacval);//设置DAC值
/*adcx=HAL_DAC_GetValue(&DAC1_Handler,DAC_CHANNEL_1);//读取前面设置DAC的值
printf("The value of adcx is %d\r\n",adcx); //显示DAC寄存器值
temp=(float)adcx*(3.3/4096); //得到DAC电压值
printf("The value of adcx is %f\r\n",temp); //显示DAC寄存器值
LED0=!LED0;
delay_ms(2000); */
}
}
|