学习文章时按照文章给出的代码用keil5仿真,结果显示十九处错误,28处警告
求解惑
代码:
void Sys_Init()
{
KEY_Start();
Uart_Start(115200);
Delay_Start(168);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
TIM5_CH1_Cap_Init(OXFFFFFFFF,83);
}
int main()
{
SysInit:Sys_Init ();
IC_Check();
if(IC_Check==1)
IC_Category();
if(IC_Check==0)
goto UartCom;
if(Cus_IC==1)
Cus_IC();
if(Adm_IC==1)
Adm_IC();
if(pwd==1)
Get_IC();
else
{
Alarm();
Cus_IC();
}
input();
KeyAct:if(input==1)
Key_Scan();
if(keyValue==1)
{
Get_Oil();
TIM5_CH1_Cap_Init(0XFFFFFFFF,84-1);
}
else
goto KeyAct;
if (Get_Oil==1)
Print();
if(Print==1)
goto UartCom;
UartCom:Uart_Com();
if(Uart_Com==1)
Mod_Price();
goto SysInit;
}
void TIM5_CH1_Cap_Init(u32 arr,ul6 psc)
{
GPIO_InitTypeDef GPIO_InitStructure;
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5,ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF;
GPIO_nitStructure.GPIO_Speed=GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_DOWN;
GPIO_Init(GPIOA,&GPIO_InitStructure);
GPIO_PinAFConfig(GPIOA,GPIO_PinSource0,GPIO_AF_TIM5);
TIM_TimeBaseStructure.TIM_Prescaler-psc;
TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_Period=arr;
TIM_TimeBaseStructure.TIM_ClockDivision=TIM_CKD_DIV1;
TIM_TimeBaseInit(TIM5,&TIM_TimeBaseStructure);
TIM5_ICInitStructure.TIM_Channel=TIM_Channel_1;
TIM5_ICInitStructure.TIM_ICPolarity=TIM_ICPolarity_Rising;
TIM5_ICInitStructure.TIM_ICSelection =TIM_ICSelection_DirectTI;
TIM5_ICInitStructure.TIM_ICPrescaler=TIM_ICPSC_DIV1;
TIM5_ICInitStructure.TIM_ICFilter=0x00;
TIM_ICInit(TIM5,&TIM5_ICInitStructure);
TIM_ITConfig(TIM5,TIM_IT_Update|TIM_IT_CC1,ENABLE);
TIM_Cmd(TIM5,ENABLE);
NVIC_InitStructure.NVIC_IRQChannel=TIM5_IRQn;
NVIC_InitStructure.NVIC_RQChannelPreemptionPriority=2;
NVIC_InitStructure.NVIC_IRQChannelSubPriority =0;
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
补充:报错内容为:
*** Using Compiler 'V6.16', folder: 'D:\Keil_v5\ARM\ARMCLANG\Bin'
FZ1.c(3): warning: implicit declaration of function 'KEY_Start' is invalid in C99 [-Wimplicit-function-declaration]
KEY_Start();
^
FZ1.c(4): warning: implicit declaration of function 'Uart_Start' is invalid in C99 [-Wimplicit-function-declaration]
Uart_Start(115200);
^
FZ1.c(5): warning: implicit declaration of function 'Delay_Start' is invalid in C99 [-Wimplicit-function-declaration]
Delay_Start(168);
^
FZ1.c(6): warning: implicit declaration of function 'NVIC_PriorityGroupConfig' is invalid in C99 [-Wimplicit-function-declaration]
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
^
FZ1.c(6): error: use of undeclared identifier 'NVIC_PriorityGroup_2'; did you mean 'NVIC_PriorityGroupConfig'?
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
^~~~~~~~~~~~~~~~~~~~
NVIC_PriorityGroupConfig
FZ1.c(6): note: 'NVIC_PriorityGroupConfig' declared here
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
^
FZ1.c(7): warning: implicit declaration of function 'TIM5_CH1_Cap_Init' is invalid in C99 [-Wimplicit-function-declaration]
TIM5_CH1_Cap_Init(OXFFFFFFFF,83);
^
FZ1.c(7): error: use of undeclared identifier 'OXFFFFFFFF'
TIM5_CH1_Cap_Init(OXFFFFFFFF,83);
^
FZ1.c(1): warning: no previous prototype for function 'Sys_Init' [-Wmissing-prototypes]
void Sys_Init()
^
FZ1.c(1): note: declare 'static' if the function is not intended to be used outside of this translation unit
void Sys_Init()
^
static
FZ1.c(1): warning: this old-style function definition is not preceded by a prototype [-Wstrict-prototypes]
void Sys_Init()
^
FZ1.c(12): warning: implicit declaration of function 'IC_Check' is invalid in C99 [-Wimplicit-function-declaration]
IC_Check();
^
FZ1.c(13): warning: comparison between pointer and integer ('int (*)()' and 'int') [-Wpointer-integer-compare]
if(IC_Check==1)
~~~~~~~~^ ~
FZ1.c(14): warning: implicit declaration of function 'IC_Category' is invalid in C99 [-Wimplicit-function-declaration]
IC_Category();
^
FZ1.c(15): warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
if(IC_Check==0)
^
FZ1.c(13): note: previous statement is here
if(IC_Check==1)
^
FZ1.c(15): warning: comparison of function 'IC_Check' equal to a null pointer is always false [-Wtautological-pointer-compare]
if(IC_Check==0)
^~~~~~~~ ~
FZ1.c(15): note: prefix with the address-of operator to silence this warning
if(IC_Check==0)
^
&
FZ1.c(15): note: suffix with parentheses to turn this into a function call
if(IC_Check==0)
^
()
FZ1.c(17): error: use of undeclared identifier 'Cus_IC'
if(Cus_IC==1)
^
FZ1.c(18): warning: implicit declaration of function 'Cus_IC' is invalid in C99 [-Wimplicit-function-declaration]
Cus_IC();
^
FZ1.c(19): error: use of undeclared identifier 'Adm_IC'
if(Adm_IC==1)
^
FZ1.c(20): warning: implicit declaration of function 'Adm_IC' is invalid in C99 [-Wimplicit-function-declaration]
Adm_IC();
^
FZ1.c(21): error: use of undeclared identifier 'pwd'
if(pwd==1)
^
FZ1.c(22): warning: implicit declaration of function 'Get_IC' is invalid in C99 [-Wimplicit-function-declaration]
Get_IC();
^
FZ1.c(25): warning: implicit declaration of function 'Alarm' is invalid in C99 [-Wimplicit-function-declaration]
Alarm();
^
FZ1.c(28): warning: implicit declaration of function 'input' is invalid in C99 [-Wimplicit-function-declaration]
input();
^
FZ1.c(29): warning: comparison between pointer and integer ('int (*)()' and 'int') [-Wpointer-integer-compare]
KeyAct:if(input==1)
~~~~~^ ~
FZ1.c(30): warning: implicit declaration of function 'Key_Scan' is invalid in C99 [-Wimplicit-function-declaration]
Key_Scan();
^
FZ1.c(31): error: use of undeclared identifier 'keyValue'
if(keyValue==1)
^
FZ1.c(33): warning: implicit declaration of function 'Get_Oil' is invalid in C99 [-Wimplicit-function-declaration]
Get_Oil();
^
FZ1.c(34): warning: implicit declaration of function 'TIM5_CH1_Cap_Init' is invalid in C99 [-Wimplicit-function-declaration]
TIM5_CH1_Cap_Init(0XFFFFFFFF,84-1);
^
FZ1.c(38): error: use of undeclared identifier 'Get_Oil'; did you mean 'Get_IC'?
if (Get_Oil==1)
^~~~~~~
Get_IC
FZ1.c(22): note: 'Get_IC' declared here
Get_IC();
^
FZ1.c(39): warning: implicit declaration of function 'Print' is invalid in C99 [-Wimplicit-function-declaration]
Print();
^
FZ1.c(40): warning: comparison between pointer and integer ('int (*)()' and 'int') [-Wpointer-integer-compare]
if(Print==1)
~~~~~^ ~
FZ1.c(42): warning: implicit declaration of function 'Uart_Com' is invalid in C99 [-Wimplicit-function-declaration]
UartCom:Uart_Com();
^
FZ1.c(43): warning: comparison between pointer and integer ('int (*)()' and 'int') [-Wpointer-integer-compare]
if(Uart_Com==1)
~~~~~~~~^ ~
FZ1.c(44): warning: implicit declaration of function 'Mod_Price' is invalid in C99 [-Wimplicit-function-declaration]
Mod_Price();
^
FZ1.c(48): error: unknown type name 'u32'
void TIM5_CH1_Cap_Init(u32 arr,ul6 psc)
^
FZ1.c(48): error: unknown type name 'ul6'
void TIM5_CH1_Cap_Init(u32 arr,ul6 psc)
^
FZ1.c(51): error: use of undeclared identifier 'GPIO_InitTypeDef'
GPIO_InitTypeDef GPIO_InitStructure;
^
FZ1.c(52): error: use of undeclared identifier 'TIM_TimeBaseInitTypeDef'
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
^
FZ1.c(53): error: use of undeclared identifier 'NVIC_InitTypeDef'
NVIC_InitTypeDef NVIC_InitStructure;
^
FZ1.c(54): warning: implicit declaration of function 'RCC_APB1PeriphClockCmd' is invalid in C99 [-Wimplicit-function-declaration]
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5,ENABLE);
^
FZ1.c(54): error: use of undeclared identifier 'RCC_APB1Periph_TIM5'
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5,ENABLE);
^
FZ1.c(54): error: use of undeclared identifier 'ENABLE'
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5,ENABLE);
^
FZ1.c(55): warning: implicit declaration of function 'RCC_AHB1PeriphClockCmd' is invalid in C99 [-Wimplicit-function-declaration]
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
^
FZ1.c(55): error: use of undeclared identifier 'RCC_AHB1Periph_GPIOA'
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
^
FZ1.c(55): error: use of undeclared identifier 'ENABLE'
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
^
FZ1.c(56): error: use of undeclared identifier 'GPIO_InitStructure'
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0;
^
FZ1.c(56): error: use of undeclared identifier 'GPIO_Pin_0'
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0;
^
FZ1.c(57): error: use of undeclared identifier 'GPIO_InitStructure'
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
28 warnings and 20 errors generated.
compiling FZ1.c...
"FZ1.c" - 19 Error(s), 28 Warning(s).
原文章:
【金山文档】 _一种基于单片机STM32的加油机系统设计
https://www.kdocs.cn/l/cdVvjvahZOqZ