Commit 1e8cfb1d authored by Minaduki Shigure's avatar Minaduki Shigure
Browse files

Update main.c

Minor fixes.
parent 6af5873b
Pipeline #1012 failed with stages
in 35 seconds
......@@ -13,10 +13,10 @@
uint64_t SPI_NULL=0x0000000000000000;
//ALIENTEK Mini STM32开发板范例代码15
//ADC实验
//技术支持:www.openedv.com
//广州市星翼电子科技有限公司
//ALIENTEK Mini STM32开发板范例代码15
//ADC实验
//技术支持:www.openedv.com
//广州市星翼电子科技有限公司
//fix include errors
#define SPI_PORT GPIOA
......@@ -36,32 +36,32 @@ uint64_t SPIx_SendReadByte16(uint64_t byte);
//u8 t=0;
//u16 dacval=0;
//u8 key;
//NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);// 设置中断优先级分组2
//NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);// 设置中断优先级分组2
u8 Data_F;
double dutyRatio,timeInterval;
double dutyRatio_L,dutyRatio_N;
double timeInterval_L,timeInterval_N;
uint64_t data1=1,data2=2,data3=3,data4=4,data5=5,data6=6;//data1,data2为频率参数 data3,data4为占空比参数
uint64_t data1=1,data2=2,data3=3,data4=4,data5=5,data6=6;//data1,data2为频率参数 data3,data4为占空比参数
uint64_t Data_R,Data_L;
delay_init(); //延时函数初始化
uart_init(9600); //串口初始化为9600
delay_init(); //延时函数初始化
uart_init(9600); //串口初始化为9600
SPIx_Init();
LED_Init(); //初始化与LED连接的硬件接口
LCD_Init(); //初始化LCD
//KEY_Init(); //按键初始化
//Adc_Init(); //ADC初始化
//Dac1_Init(); //DAC通道1初始化
LED_Init(); //初始化与LED连接的硬件接口
LCD_Init(); //初始化LCD
//KEY_Init(); //按键初始化
//Adc_Init(); //ADC初始化
//Dac1_Init(); //DAC通道1初始化
POINT_COLOR=DARKBLUE;
LCD_ShowString(52,50,200,16,16,"Nanjing University");
LCD_ShowString(60,70,200,16,16," EE Group 4 ");
LCD_ShowString(60,90,200,16,16,"Minaduki Shigure");
POINT_COLOR=RED;//设置字体为红色
POINT_COLOR=RED;//设置字体为红色
LCD_ShowString(60,110,200,16,16,"Frequency Meter");
//LCD_ShowString(60,130,200,16,16,"WK_UP:+ KEY0:-");
//显示提示信息
POINT_COLOR=BLUE;//设置字体为蓝色
//显示提示信息
POINT_COLOR=BLUE;//设置字体为蓝色
LCD_ShowString(30,130,200,16,16,"Frequency:");
LCD_ShowString(30,170,200,16,16,"Duty Ratio:");
LCD_ShowString(30,210,200,16,16,"Time Interval:");
......@@ -77,7 +77,7 @@ uint64_t SPIx_SendReadByte16(uint64_t byte);
while(1)
{
dutyRatio_N=(data4*100.0)/(data3+data4);
if(abs(dutyRatio_N-dutyRatio_L)>1.5)
if(fabs(dutyRatio_N-dutyRatio_L)>1.5)
{
dutyRatio=dutyRatio_N;
dutyRatio_L=dutyRatio;
......@@ -90,7 +90,7 @@ uint64_t SPIx_SendReadByte16(uint64_t byte);
dutyRatio = 100 - dutyRatio; //Fix the ratio problem due to the change of variables.
POINT_COLOR=BLUE;//设置字体为蓝色
POINT_COLOR=BLUE;//设置字体为蓝色
LCD_ShowxFloat(30,150,data1,0,10,16,0);
LCD_ShowxFloat(30,190,dutyRatio,2,10,16,0);
LCD_ShowxFloat(30,230,timeInterval,4,10,16,0);
......@@ -156,8 +156,8 @@ uint64_t SPIx_SendReadByte16(uint64_t byte);
timeInterval=data5*20/5000.0;break;
}
}
timeInterval_N=timeInterval; //先给dutyRatio_N 运算后给dutyRatio显示
if(abs(dutyRatio_N-dutyRatio_L)>5.0)
timeInterval_N=timeInterval; //先给dutyRatio_N 运算后给dutyRatio显示
if(fabs(dutyRatio_N-dutyRatio_L)>5.0)
{
timeInterval=timeInterval_N;
timeInterval_L=timeInterval;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment