Makee2333 2024-03-23 21:46 采纳率: 0%
浏览 13

STM32F407ZGT6代码及文章求解答

学习文章时按照文章给出的代码用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

  • 写回答

2条回答 默认 最新

  • 码农阿豪 Java领域优质创作者 2024-03-23 21:46
    关注
    让阿豪来帮你解答,本回答参考chatgpt3.5编写提供,如果还有疑问可以评论或留言
    问题解答 根据给出的代码,无法准确判断其中出现的错误和警告具体是什么,需要具体查看编译器输出的报错信息,才能找到对应的解决方案。 一般来说,编译器输出的错误信息包括错误代码、错误行数、错误描述等信息。比如:
    main.c:23:2: error: expected identifier before ‘.’ token
      GPIO_InitStructure.<span>GPIO_Pin&#61;GPIO_Pin_0;
      ^
    main.c:23:2: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token
    main.c:28:19: error: ‘TIM5_ICInitStructure’ undeclared (first use in this function)
     main.c:28:19: note: each undeclared identifier is reported only once for each function it appears in
    main.c:29:21: error: ‘TIM_Channel_1’ undeclared (first use in this function)
       TIM5_ICInitStructure.<span>TIM_Channel&#61;TIM_Channel_1;
                         ^
    main.c:29:38: error: ‘TIM_ICPolarity_Rising’ undeclared (first use in this function)
       TIM5_ICInitStructure.<span>TIM_ICPolarity&#61;TIM_ICPolarity_Rising;
                                          ^
    main.c:29:76: error: ‘TIM_ICSelection_DirectTI’ undeclared (first use in this function)
       TIM5_ICInitStructure.TIM_ICSelection &#61;TIM_ICSelection_DirectTI;
                                                                                ^
    

    以上是示例的报错信息,其中包括错误代码、错误行数以及错误描述。根据错误信息,可以逐个解决问题。 例如,在第23行代码中,出现了错误:expected identifier before ‘.’ token,意思是在“.”操作符之前应该有一个标识符,但是此处缺失了。这个问题要具体看代码才能解决。 总之,解决编译器报错或者警告的方法,是具体查看错误信息,针对每一个问题逐个解决。如果有多个问题,可以先解决一个再解决下一个。

    评论

报告相同问题?

问题事件

  • 修改了问题 3月23日
  • 创建了问题 3月23日

悬赏问题

  • ¥15 socket通信实现多人聊天室疑惑
  • ¥15 DEV-C++编译缺失
  • ¥33 找熟练码农写段Pyhthon程序
  • ¥100 怎么让数据库字段自动更新
  • ¥15 antv g6 力导向图布局
  • ¥15 quartz框架,No record found for selection of Trigger with key
  • ¥15 锅炉建模+优化算法,遗传算法优化锅炉燃烧模型,ls-svm会搞,后面的智能算法不会
  • ¥20 MATLAB多目标优化问题求解
  • ¥15 windows2003服务器按你VPN教程设置后,本地win10如何连接?
  • ¥15 求一阶微分方程的幂级数