Application of MDK project macro definition

Publisher:Xiaoxue666Latest update time:2019-04-19 Source: eefocusKeywords:MDK Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

This macro definition refers to the macro definition under the project's Options window--"C/C++"--"Preprocerssor Symbols".

Here the macro definition allows the compiler to selectively compile certain codes. For example:


#if defined(LCD_MODEL_AT043)

 

    #define C_GLCD_H_PULSE 41

    #define C_GLCD_H_FRONT_PORCH 10

    #define C_GLCD_H_BACK_PORCH 10

 

    #define C_GLCD_V_PULSE 10

    #define C_GLCD_V_FRONT_PORCH 2

    #define C_GLCD_V_BACK_PORCH 2

 

#elif defined(LCD_MODEL_AT070)

 

    #define C_GLCD_H_PULSE 20

    #define C_GLCD_H_FRONT_PORCH 210

    #define C_GLCD_H_BACK_PORCH 46

 

    #define C_GLCD_V_PULSE 10

    #define C_GLCD_V_FRONT_PORCH 22

    #define C_GLCD_V_BACK_PORCH 23

 

#else

 

    #define C_GLCD_H_PULSE 20

    #define C_GLCD_H_FRONT_PORCH 250

    #define C_GLCD_H_BACK_PORCH 50

 

    #define C_GLCD_V_PULSE 5

    #define C_GLCD_V_FRONT_PORCH 5

    #define C_GLCD_V_BACK_PORCH 5

 

#endif



In the above code, because LCD_MODEL_AT043 is defined in the project's macro definition, only the following macro definitions will be compiled:

    #define C_GLCD_H_PULSE 41

    #define C_GLCD_H_FRONT_PORCH 10

    #define C_GLCD_H_BACK_PORCH 10

 

    #define C_GLCD_V_PULSE 10

    #define C_GLCD_V_FRONT_PORCH 2

    #define C_GLCD_V_BACK_PORCH 2



The application scenarios of this macro definition are as follows:

If your program may be used for two LCD screens: 4.3 inches and 7 inches, you can do this:


Create two project objects in the "Project Targets" under the "Manage Project Items" window (if you only created one before, you can just add another one).

At this time, when you go back to MDK, you can see two options in the drop-down box next to the download button.



This is the project object you just created.


Select the first 4.3-inch project object and add LCD_MODEL_AT043 in the project macro definition.


Select the second 7-inch project object and add LCD_MODEL_AT070 in the project macro definition.


This is done.




When you want to use the 4.3-inch screen program, select the 4.3-inch screen project object in the drop-down box, and the macro definition LCD_MODEL_AT043 will take effect, only compiling your program



#if defined(LCD_MODEL_AT043)

 

    #define C_GLCD_H_PULSE 41

    #define C_GLCD_H_FRONT_PORCH 10

    #define C_GLCD_H_BACK_PORCH 10

 

    #define C_GLCD_V_PULSE 10

    #define C_GLCD_V_FRONT_PORCH 2

    #define C_GLCD_V_BACK_PORCH 2



part.




You can also use this method to separate the debugging program from the official version of the program. When you need some debugging information during debugging, you can include it with a macro definition, such as:


#if defined(debug)

 

  shellSnd("It`s debuging status now!");

 

#endif


Keywords:MDK Reference address:Application of MDK project macro definition

Previous article:J-Link V8 Firmware Fix
Next article:Understanding AREA and ENTRY in assembly

Recommended ReadingLatest update time:2024-11-16 23:54

STM32 Keil-MDK Project Template V3.5 Firmware Library
I have been using the 3.3 firmware library. I haven't updated the 3.4 one for a long time. Now I can't help it. I built a new V3.5 project template using the latest MDK4.20. There is basically no interface change from 3.5 to 3.3 for general users. At present, it seems that only the file location of some definitions ha
[Microcontroller]
About mixed programming of C and assembly in ARM (under MDK)
About mixed programming of C and assembly in ARM (under MDK)  Mainly: Inline assembly and embedded assembly under MDK Mainly from: http://bbs.21ic.com/icview-156494-1-1.html  ( Tips: How to embed assembly language in MDK C language for Cortex-M3 )   ============================================================ ****
[Microcontroller]
Keil (MDK-ARM) series tutorial (three)_project target option configuration (I)
II. Main Points This article mainly describes the configuration of target options. However, in order to let more people understand what target options are, we will first briefly describe the meaning and differences between workspace, project, and target. 1. Two ways to open target options 1. Click the target option
[Microcontroller]
Keil (MDK-ARM) series tutorial (three)_project target option configuration (I)
MDK hardware debugging_Display print information in the Debug printf Viewer window_ITM
When debugging code, everyone likes to use the printf function to output some print information to prompt the execution status of their own code. When I first came into contact with this debugging method, the way I used was to waste a serial port of a chip, and then use the TTL to USB module to print prompt informatio
[Microcontroller]
MDK hardware debugging_Display print information in the Debug printf Viewer window_ITM
Compiler intrinsics for controlling IRQ and FIQ interrupts - based on Keil MDK
The compiler intrinsic functions __disable_irq, __enable_irq, __disable_fiq and __enable_fiq are used to control IRQ and FIQ interrupts. These intrinsic functions can only be used when the processor is in privileged mode, because these functions change the registers CPSR and SPSR (ARM7, ARM9, etc.) or PRIMASK and FAU
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号