PIC microcontroller C language programming (7)

Publisher:平和思绪Latest update time:2013-02-05 Source: dzsc Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
  In "PIC Microcontroller C Language Program (1) ~ (6)", we introduced some basic features and main contents of C language, and used C language to write some basic programs and utilities for learning PIC microcontrollers. The above source program needs to generate target code. Hex file, and burn it into the chip of PIC microcontroller, and then run it to verify the correctness of the source program. This process must be completed with the development tools of PIC microcontroller. This article introduces these development tools and their installation methods.

  10. MPLAB IDE7.40 Integrated Development Environment

  MPLAB IDE is an integrated development environment (IDE: Integrated Development Environment) for PIC series microcontrollers launched by Microchip. It can be run under the Windows operating system of a PC. There are many versions of MPLAB IDE. The following introduces the main functions of the MPLAB IDE7.40 integrated development environment.

  1. Edit the program

  In MPLAB IDE (version 7.40, the same below), you can write and edit source programs for PIC microcontrollers (both assembly language and C language programs are acceptable), and you can also write and edit other text files.

  2. Assembler

  Under MPLAB IDE, PIC assembly language source programs are assembled to generate a variety of target codes (such as .hex) to support a variety of programmers from Microchip.

  3. Compile the program

  Under MPLAB IDE, the PIC C language source program is compiled and linked through the PIC C and PIC C18 C compilers to generate the target code (.hex).

  4. Simulation debugging

  Using the MPLABSI MSimulatov command in MPLAB IDE, you can simulate and debug the target code (actually the source program) of the PIC series microcontroller. Through simulation debugging, you can not only find out the problems in the program design, but also observe the entire process of the C language program running, and quantitatively observe the program running time, such as the delay value of the delay function. When I was learning C language to edit a certain function source program of the PIC microcontroller, I often used simulation debugging to intuitively observe the running process of the source program and quickly mastered the characteristics and running mode of the C language program. In the following series, the detailed method of source program simulation debugging will also be introduced, so please pay attention. MPLAB IDE7.40 integrated development environment has more functions, which are limited to space and are not described here. Readers can refer to relevant books.

  11. Introduction to PIC C and PIC C18C Compilers

  PIC C and PIC C18C compilers are C language source program compilers developed by Australia's HI-TECH company, referred to as C compilers, which fully comply with the US ANSIC standards.

  This compiler is a high-performance C compiler software for PIC series microcontrollers. PIC C can be used for PIC16 microcontroller series products, and PIC C18 can be used for PIC18 microcontroller series products. Both can run under the MPLAB IDE integrated development environment (higher version). The C language source program edited by the user must be compiled and linked with the C compiler to generate an absolute target file and other formats of files, such as .hex (target code), for program application and debugging. Therefore, in addition to understanding the hardware functions of the PIC microcontroller, MPLAB IDE and PIC C and PIC C18C compilers are also indispensable when developing PIC microcontroller series products using C language. The main functions of PIC C and PICC18C compilers are introduced below.

  1. Working method

  Run under MPLAB IDE integrated development environment (higher version, such as MPLAB IDE7.40) to create a project and generate the target code. Hex file, that is, burn the PIC microcontroller source code into the file (.hex) of the corresponding PIC chip.

  2.Support simulation

 

  Supports hardware simulation MPLAB ICE (In-CircuitEmulator); supports software simulation MPLAB SIM (simalator); supports low-cost online debuggers MPLAB ICD and MPLABICD2 (In-circuit debugger).

  3. Hybrid Programming

  PIC C and PIC C18C compilers support mixed programming of assembly language and C language.

  4. Debug source program

  PIC C and PIC C18C compilers run under MPLAB IDE, allowing source program debugging. During debugging, breakpoints can be set on the source program, and the program will automatically stop when it reaches the breakpoint, allowing the debugger to observe and modify variable values; it allows single-step and continuous program operation, etc. These functions are extremely helpful for learning C language. [page]

    12. PIC microcontroller programming device

  The function of the PIC microcontroller burning programmer (referred to as the programmer) is to burn the target code .hex of the PIC microcontroller program generated after assembly or compilation into the chip to facilitate the operation of the program.

  There are many types of programmers for PIC microcontrollers, which can be summarized into two categories: one is a simple programmer, and the other is a so-called full-series programmer. Simple programmers can burn fewer chip models, and the burning speed is slow, and most of them are chips of mid-level PIC microcontrollers, such as PIC16F84/627/628/87X... The so-called full-series programmers refer to those programmers that can burn multiple types of PIC microcontrollers, and their burning speed is fast. Simple programmers are cheap, priced at 200 to 300 yuan, and are suitable for learning PIC microcontrollers; the latter are mostly used by electronic companies to develop electronic products, and the price is higher (about 800 yuan).

  The following introduces a simple programmer, which consists of two parts.

  The first is the hardware part, which is connected to the PC through the RS232 port when working. Figure 10 is its working block diagram; the second is the PC software Icprog1.05 required for programming the programmer, and its programming interface is shown in Figure 11.

Fig.10

Fig.11

  This programmer can program 8, 18, 28, 40 and other pin products of PIC microcontroller chips. It is easy to use and sufficient for learning PIC microcontroller programming.

  13. Installation of MPLAB IDE Version 7.40 and PIC C Compiler

  The CD that comes with this article contains two compression software: MPLABIDE-V7.40 Zip and PICC8.50 rar, as shown in Figure 12. They can be used for learning PIC microcontroller C language experiments.

Fig.12

  1. Installation of MPLAB IDE version 7.40

  Insert the CD containing the above two compression software into the CD-ROM drive of the PC. On the desktop of the monitor, click "My Computer" with the mouse, click "Open" in its drop-down menu, find "My CD" on the desktop and open it, and the two compression software icons shown in Figure 12 will appear. Use the mouse to open them respectively and click "Copy", then open the E disk respectively and paste them to the E disk (you can also paste them to the D disk or F disk). First install the MPLAB IDE7.40 version software. The installation process is as follows:

  (1) Double-click "My Computer" with the mouse, open Disk E on the desktop, find the compression software MPLAB-IDE icon, and click it with the mouse. Move the mouse to "winRAR" in the drop-down menu, and then move the mouse to the "Extract to MPLAB-IDE-V7.4 (/E)" command and click it to generate the decompressed icon, as shown in Figure 13.

Fig.13

  (2) Click the MPLAB-IDE icon in Figure 13. In the drop-down menu, click the "Open" command to generate multiple files.

[page]

    (3) Select (click) the MPLAB-V7.40 installation icon in Figure 14 from among the multiple files. In the lower menu, click “Open” to generate the “Check Working System” file in the “Installation Wizard” in Figure 15. At this time, you can observe the operation of the automatic installation progress display interface.

Fig.14

Fig.15

  (4) After the automatic installation is completed, the "Welcome to modify, restore, or cancel the program function file" shown in Figure 16 will be generated.

Fig.16

  Select Repair (Restore - that is, use the mouse to click a black dot in the small circle on the left of Repair to restore all the program's functional features), and then click Next at the bottom of Figure 16 to generate the MPLAB T00Ls V7.40 file in Figure 17. This file is for automatic installation of the new software MPLAB IDE7.40, so you can see the colored slider on the file increasing to the right, and you can also see new characters being generated quickly and continuously to the right of "validating install". Just wait a little while, and the colored slider will be filled to the right, and the installation completion interface in Figure 18 will be automatically generated.

Fig.17

Fig.18

[page]

    (5) After clicking the "Finish" command at the bottom of Figure 18, the PC automatically shuts down and then automatically restarts, and a shortcut icon for "MPLAB IDE" V7.40 is automatically generated on the desktop, as shown in Figure 19. At this point, the software installation is complete and can be used.

Fig.19

  (6) If the reader is interested, he can observe the interface of MPLAB IDE V7.40. The method is to double-click the MPLAB IDE V7.4 icon in Figure 19 and run the program. The running interface of MPLAB IDE V7.40 integrated development environment will appear on the screen, as shown in Figure 20. The interface consists of "title bar", "menu bar", "toolbar", "work area", "status bar", etc. The status bar is at the bottom and is used to display the current chip model, address pointer, working register value, crystal frequency and other information.

Fig. 20

Reference address:PIC microcontroller C language programming (7)

Previous article:PIC microcontroller C language programming (8)
Next article:PIC microcontroller C language programming (6)

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号