FMUSER Wirless Transmit Video And Audio More Easier !

[email protected] WhatsApp +8618078869184
Language

    STM32 microcontroller design extern global variable definitions shall be resolved

     

    "Writing systcik today_ When using the handler() interrupt function, an error is always reported. The global variable extern U16 ntime (ntime -- written in stm32f10x) defined at the beginning_ In the systick interrupt function of it. C), but errors are always reported during compilation. Baidu has a solution after that, I have noticed the extern variable before, but I haven't thought about its use carefully. When I encounter it today, I must understand it and the general function of this keyword (just the general function, the breadth and depth of C dare not talk about it); When you build a header file library, you often encounter a problem, that is, you define a temperature variable in file a and want to pass its value to file B for use, but the function in file a operation cannot take return parameters, such as interrupt service function. What should you do? If you define temperature in a, then include A.H and B.H in includes. H, and then put includes. H in a.c and B.C, there is no problem with single compilation, but there will be problems when linking, “Symbol temple mulTIply defined(by A.o and B.o)” This variable has been defined many times!!! The solution is: After defining the temp variable in a, declare it in B with extern, for example: 1. Define temp in a and assign value: U16 temp2 = 0; 2. Declare extern U16 temp2 in B; This is just a declaration, no assignment, or an error will be reported! Symbol temp2 mulTIply defined (by catch_ pwm.o and app.o) Note the difference between variable definition and variable declaration: The variable definition uses the form of "data type + variable name", and the compiler needs to allocate memory units to it; The variable declaration uses the form of "external variable type + variable name" to tell the compiler that this variable will be defined in other external C files. I only use it externally here. The compiler will not allocate memory space to it, but will allocate memory space to it when it really encounters the variable definition. //////////////////The following is the "Juhai" de post/////////////////////////////////// 1. Common variables are defined as global variables If it is a common type, it can be defined directly in the *. C file without the *. H file, and declared with extern at the calling file, because the compiler can recognize common types. For example, in a my. C file, I defined char name [10]; In other files, just use extern char name [] (because it is a declaration, the size of a one bit array can be omitted, but it is not recommended to use pointers. Comparing pointers and arrays is two different things). Tell the compiler that I have defined this variable. Take your time to find out. This makes sense because char is a type that the compiler can recognize autonomously. 2. A custom structure type is defined as a global variable Unlike ordinary types, the compiler will not recognize your custom type without notifying the compiler in advance. At this time, the *. H file appears. Isn't the definition of structure type not occupying memory? Well, I put the definition of the large structure in the *. H file, so that no matter how many times you incude, the memory will not be occupied. In addition, there is another advantage. You can include this *. H file in other files, so that the compiler can recognize your custom type in this file. Isn't the purpose achieved? If I defined it in global. H typedef struct _ POSITION { int x; int y; }POSITION; Then I can implement the definition of global variables in a global. C file, but I need to include the *. H file, such as include “global.h” POSITION current,; Thus, the variable cunrrent is defined. When this variable is referenced in other files, as long as external position current; Declare it, and then you can use it. However, this file must also include "global. H", because if it is not included, the position type is not recognized in this file. 1. How to reference a defined global variable? Answer: extern can refer to the header file or the extern keyword. If you refer to a global variant declared in the header file by referring to the header file, you will report an error during compilation if you write it wrong. If you use extern, you will not report an error during compilation if you make the same error, An error is reported during connection. 2. Can global variables be defined in multiple. C files? Why? A: Yes, you can declare a global variable with the same name in the form of static in different C files. Global variables with the same name can be declared in different C files, provided that only one C file can assign an initial value to this variable, and the connection will not make an error. OVER!, Read the full text, technical section Working principle of single chip microcomputer memory and concept analysis of chip selection and bus Definition and analysis of extern global variable in STM32 Single Chip Microcomputer Design Summary and analysis of common problems in AVR MCU C programming Write and share DTMF dialing program based on PIC12C508 Based on PIC MCU control temperature sensor temperature measurement design, Download enthusiast app Create an electronic circle of your contacts Pay attention to wechat of electronic enthusiasts Interesting and informative information and technology dry goods Focus on enthusiast class Lock in the live broadcast of the latest course activities and technologies and collect them 0 collections Share: 1. Comments Lin Chaowen PCB Design: pads tutorial, pads video tutorial, Zheng Zhenyu teacher: Altium designer tutorial, Altium designer video tutorial, Zhang Fei actual combat electronic video tutorial, Zhu Youpeng teacher: Hisilicon hi3518e tutorial, hi3518e video tutorial, Li Zeng teacher: signal integrity tutorial, high-speed circuit simulation tutorial, Huawei Hongmeng system tutorial, harmonyos video tutorial, saisheng: EMC design tutorial, EMC video tutorial Mr. Du Yang: STM32 tutorial, STM32 video tutorial, Tang zuolin: basic C language tutorial, basic C language video tutorial, Zhang Fei: Buck Power tutorial, buck power video tutorial, punctual atom: FPGA tutorial, FPGA video tutorial, Mr. Wei Dongshan: embedded tutorial, Embedded video tutorial Zhang Xianfeng: C language basic video tutorial Xu Xiaogang: Modbus communication video tutorial Wang Zhentao: NB IOT development video tutorial mill: FPGA tutorial, zynq video tutorial c language video tutorial linux driver development video tutorial Zhu Youpeng: u-boot source code analysis video tutorial harmonyos,  Press and hold the slider and drag to the far right Learn about new features Published, relevant recommendations How to use the GPIO of STM32 single chip microcomputer to control the LED display The ODR register is readable and writable: it can control the pin to be high level and the pin to be low level. Pin write 1 GPIO for bit Published at 15:45, November 1, 2018 • 6 readings Advanced control timer TIM1 and Ti based on STM32 single chip microcomputer The general timer of STM32 is a 16 bit automatic loading counter (CNT) driven by programmable prescaler (PSC) Published at 16:10, October 30, 2018 • 72 readings Control of running lamp based on STM32 single chip microcomputer First of all, you should know that ordinary IO has two functions, one is input and the other is output. Then subdivide the input and output into which mode to output and which Published on October 30, 2018 16:02 • 54 readings How to select the startup code of stm32 ● small capacity products refer to stm32f101xx and stm32f10 with flash memory capacity between 16K and 32K bytes Published at 16:00, October 30, 2018 • 41 readings Control of running water lamp based on STM32 single chip microcomputer 1. When we follow the routine to create our own project, there are undefined in the GPIO library file. When we just started learning new Published at 15:42, October 30, 2018 • 69 readings The solution of second interrupt source and alarm clock interrupt source based on STM32 single chip microcomputer The computer should

     

     

     

     

    List all Question

    Nickname

    Email

    Questions

    Our other product:

    Professional FM Radio Station Equipment Package

     



     

    Hotel IPTV Solution

     


      Enter email  to get a surprise

      fmuser.org

      es.fmuser.org
      it.fmuser.org
      fr.fmuser.org
      de.fmuser.org
      af.fmuser.org ->Afrikaans
      sq.fmuser.org ->Albanian
      ar.fmuser.org ->Arabic
      hy.fmuser.org ->Armenian
      az.fmuser.org ->Azerbaijani
      eu.fmuser.org ->Basque
      be.fmuser.org ->Belarusian
      bg.fmuser.org ->Bulgarian
      ca.fmuser.org ->Catalan
      zh-CN.fmuser.org ->Chinese (Simplified)
      zh-TW.fmuser.org ->Chinese (Traditional)
      hr.fmuser.org ->Croatian
      cs.fmuser.org ->Czech
      da.fmuser.org ->Danish
      nl.fmuser.org ->Dutch
      et.fmuser.org ->Estonian
      tl.fmuser.org ->Filipino
      fi.fmuser.org ->Finnish
      fr.fmuser.org ->French
      gl.fmuser.org ->Galician
      ka.fmuser.org ->Georgian
      de.fmuser.org ->German
      el.fmuser.org ->Greek
      ht.fmuser.org ->Haitian Creole
      iw.fmuser.org ->Hebrew
      hi.fmuser.org ->Hindi
      hu.fmuser.org ->Hungarian
      is.fmuser.org ->Icelandic
      id.fmuser.org ->Indonesian
      ga.fmuser.org ->Irish
      it.fmuser.org ->Italian
      ja.fmuser.org ->Japanese
      ko.fmuser.org ->Korean
      lv.fmuser.org ->Latvian
      lt.fmuser.org ->Lithuanian
      mk.fmuser.org ->Macedonian
      ms.fmuser.org ->Malay
      mt.fmuser.org ->Maltese
      no.fmuser.org ->Norwegian
      fa.fmuser.org ->Persian
      pl.fmuser.org ->Polish
      pt.fmuser.org ->Portuguese
      ro.fmuser.org ->Romanian
      ru.fmuser.org ->Russian
      sr.fmuser.org ->Serbian
      sk.fmuser.org ->Slovak
      sl.fmuser.org ->Slovenian
      es.fmuser.org ->Spanish
      sw.fmuser.org ->Swahili
      sv.fmuser.org ->Swedish
      th.fmuser.org ->Thai
      tr.fmuser.org ->Turkish
      uk.fmuser.org ->Ukrainian
      ur.fmuser.org ->Urdu
      vi.fmuser.org ->Vietnamese
      cy.fmuser.org ->Welsh
      yi.fmuser.org ->Yiddish

       
  •  

    FMUSER Wirless Transmit Video And Audio More Easier !

  • Contact

    Address:
    No.305 Room HuiLan Building No.273 Huanpu Road Guangzhou China 510620

    E-mail:
    [email protected]

    Tel / WhatApps:
    +8618078869184

  • Categories

  • Newsletter

    FIRST OR FULL NAME

    E-mail

  • paypal solution  Western UnionBank OF China
    E-mail:[email protected]   WhatsApp:+8618078869184   Skype:sky198710021 Chat with me
    Copyright 2006-2020 Powered By www.fmuser.org

    Contact Us