While launching the PIC series of single-chip microcomputer products, Microchip also launched corresponding software development and hardware development tools, such as PIC online emulator, MPLAB integrated development software, MPSIM software emulator, MPASM macro assembler and PIC universal programmer. In addition, the development of PIC series single-chip microcomputers in China is also very rapid. Many companies or research institutes have also launched corresponding development devices, including both low-priced software emulators and programmers suitable for beginners and high-end development application devices suitable for product development. Some high-end developers can also support C compilers (such as MP-C) and fuzzy logic development systems. These development devices can run independently or online with a PC. In short, the tools for developing PIC single-chip microcomputers are not only very mature but also diverse.
When assembling the source program of the PIC single-chip microcomputer on a PC, it can be done under DOS conditions or under Windows conditions. The following will introduce the methods and steps of assembling the source program under Windows.
1. MPLAB, the PIC integrated development software under Windows
MPLAB is the integrated development software for PC Windows provided by Microchip for PIC single-chip microcomputer development products. MPLAB has developed into many versions from the early days to the present: such as MPLAB V3.01, V3.02, V4.0, V4.99 and V5.0. Each version is backward compatible, so even though there are so many types of PIC microcontrollers, users only need to choose the corresponding version of MPLAB integrated development software to achieve their development goals.
(1) Features and installation of MPLAB
MPLAB is an easy-to-learn and easy-to-use integrated development tool software for PIC microcontroller products. The software consists of tool software such as MPLAB editor, MPLAB project manager, MPASM assembler (Windows version) and MPLAB-SIM simulation debugger. MPLAB can help you debug source code, observe program flow, debug and optimize firmware production design of PIC microcontroller applications. The functions and usage of the above-mentioned various software will be introduced through examples in the next few issues of this newspaper.
MPLAB integrated development software has the following hardware and software configuration requirements for the computer system: Microsoft Windows 3.X, 95 and 98 versions are all acceptable; standard keyboard and mouse; 4MB (preferably 16MB or more) of memory and a VGA or higher monitor. MPLAB is easy to install. Anyone familiar with PCs can use the MPLAB SETUP.EXE file and related prompts in the disk or CD-ROM to install it. If you are a beginner, you can ask a computer expert to install it. When installing MPLAB software, it is best to paste the Microchip/MPLAB shortcut icon on the display screen for easy operation.
(2) MPLAB desktop system
The biggest difference between the Windows operating system and the DOS operating system is the extensive use of graphical operating interfaces. Therefore, dialog boxes are the most common thing users come into contact with during Windows operation. All MPLAB functions can be operated through the menu commands in the MPLAB desktop (dialog box).
After MPLAB integrated development software is installed on your PC, turn on the PC and click the shortcut icon Microchip on the monitor with your mouse to see the MPLAB desktop on the monitor, as shown in the attached figure (V4.99 version). The desktop is a resizable window. The characters on the left of the top of the MPLAB desktop are the title bar (MPLAB); below the title bar is the menu bar (MENU), below the menu bar is the toolbar, and at the bottom is the status bar. The menu bar in the desktop window is a drop-down type.
MPLAB has a total of multiple menu options (9 for V322 and V499, and 8 for V301). All MPLAB functions can be accessed through a drop-down menu. The underlined characters in the menu represent accelerators (Key Accelerators). When the menu is pulled down, click the character key with the mouse to immediately execute the function.
The functions of the various menus of MPLAB will be explained in detail by the author through specific program assembly application examples.
Chengdu Ding Jinyuan
Knowledge contest question:
26. Send the number 0x08 to the working register W of the PIC16C54 microcontroller. Please write the corresponding source program listing.
2. Create PIC microcontroller source program in MPLAB
The author will take the source program PIC count.ASM of the PIC16C55 microcontroller pulse counting test circuit (when counting, port RA1 is decimal code input and port RB is binary code output) as an example to introduce the method of editing (creating) PIC microcontroller source program in MPLAB integrated development environment. The operation steps are as follows.
(1) Open the MPLAB desktop (window) and blank editing window. Turn on the PC and start running Windows. Under the Windows management program, click the icon Microchip (shortcut) on the display screen with the mouse to start running MPLAB integrated development software. At this time, the MPLAB desktop will be displayed on the screen (see the attached picture in the article "Assembly and Solidification of Source Programs (I)" in the 25th issue of this year). From the MPLAB desktop (window), click the leftmost File in the MPLAB menu bar to open the File drop-down menu. Then click the command New Source in the drop-down menu to open a blank editing window. In this window, type the PIC 16C55 COUNT.ASM source program on the keyboard and edit it (take MPLAB V3.01 as an example):
LIST P=16C55
#INCLUDE P16C5X.INC
COUNT EQU 1EH
ORG 0
START
MOVLW 0
MOVWF PORTB; Set port B to output
TRIS PORTB
CLRF COUNT; Set counter COUNT to zero
LOOP
BTFSS PORTA, 1; Determine whether switch K is pressed?
GOTO INCOUNT; Press switch K to jump to IN-
; COUNT
ENDLOOP
GOTO LOOP; If the switch is not pressed, continue the loop
; Determine
whether INCOUNT
INCFG COUNT, 1; counter COUNT + 1
MOVF COUNT, W
MOVWF PORTB; output count value from port B
DEBOUNCE
BTFSS PORTA, 1; determine whether switch K is released?
GOTO DEBOUNCE; if not released, continue to determine
GOTO LOOP; switch K is released and restart
ORG 0x1FF; reset vector
GOTO START
END
Description: When creating a source program under the MPLAB integrated development environment, the pseudo-instruction List (list selection instruction) indicator should be used at the beginning of the source program file to specify the type (object) of processing. Therefore, the beginning of the above source program is List P = 16C55. The "P=" is the processing type, which means setting the microcontroller to 16C55 (chip). Then the pseudo-instruction #include P16C5XINC is used, which means that MPLAB should read all the set files of the microcontroller F16C55 to be processed (type) into the source program here when needed. This pseudo instruction greatly simplifies the code setting in the source program. For example, PORTB, TRIS and other special function registers are no longer assigned values using the EQU pseudo instruction.
The pseudo instruction immediately following the above in the source program is ORG, which represents the starting address of the program. Therefore, in a source program, the ORG pseudo instruction can be used multiple times as needed to locate. In the above source program, ORG is used twice. It is worth noting that in the PIC series of microcontrollers, the reset vector for the primary product PIC16C54/55 is 1FFH; PIC16C56 is 3FFH; PIC16C57/58 is 7FF; and the reset vectors for intermediate and advanced products are 000H and 0000H. It can be seen that when establishing the source program of the PIC microcontroller, it is very necessary to use some pseudo instructions, which can be used to complete some specific functions for establishing the source program, greatly simplifying the compiled source program. The functions of each instruction after the source program have been explained in the comments and will not be repeated here. 3 The source program file in MPLAB is saved to the specified directory and loaded
On the PC screen, after typing and editing the source program (COUNTASM) with the keyboard, use the mouse button to open the File pull-down menu, select the Save command, and click Save with the mouse button to open the window in Figure 1 (the directory path is C:PROGRA~1MPLAB). In the File Name column of this window (title - Save File As), select the path, enter the file name PIC COUNTASM (user-defined name) with the keyboard, and then click OK with the mouse button to save the source program file with the specified file name PIC COUNTASM to the specified directory. This process is usually called saving the PIC microcontroller (microcontroller) source program (COUNTASM).
In the MPLAB integrated development environment, on the MPLAB desktop, click the File drop-down menu with the mouse button. In the menu, select the Open Source command, and then click OPEN SOURCE with the mouse button to open the dialog box (window) of Figure 2. Select the directory path in this dialog box (same as before). In the "List File Types" column of the window, select Source File, and then use the mouse button to click the arrow button on the scroll groove on the right side of the file name window several times (you can also drag the scroll block on the groove) to transfer the established source program PIC COUNTASM to the file name window. Then use the mouse button to click the source program name PIC COUNTASM, and you can click the file name into the file name column. At this point, the source program is loaded. Click OK with the mouse button, and you can see the source program file appear again in the title bar of the selected path and file name (C:PROGRA~1MPLABPIC COUNT.ASM) on the MPLAB desktop of the PC display as shown in Figure 3. The programmer can confirm that the source program has been saved and loaded.
From the software operation process of establishing, editing, saving and loading the source program COUNTASM in the MPLAB integrated development software introduced above, it can be seen that in order to assemble the source program COUNTASM in MPLAB, it is necessary to perform multiple operations on the PC to achieve the purpose of assembling the source program (the loading step can be omitted).
In order to enable PIC microcontroller beginners to quickly master the source program assembly method, the author recommends that beginners should do more hands-on operations on the PIC microcontroller and repeatedly practice the early assembly operation process of establishing, editing, saving and loading the PIC microcontroller source program, so as to make as few mistakes as possible when learning the assembly method to be introduced, and enhance the confidence in learning the PIC microcontroller source program assembly. For this reason, the author recommends the following simplest PIC microcontroller test source program so that beginners can practice repeatedly.
LIST P=PIC16C84
#INCLUDE P16C84INC
ORG 0
START
MOVLW 0x04
GOTO START
END
Ding Jinyuan, Chengdu
Knowledge contest question:
28. In the above text, in the end instruction MOVLW, what is the value range (0x?) of the number sent to W?
Previous article:How to select PIC microcontroller memory bank 0 or 1
Next article:PIC 8-bit microcontroller source program assembly and curing under Windows (Part 2)
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Hall Effect Current Sensors in Telecom Rectifiers and Server Power Supplies
- MSP430 has 5 low power modes
- Some recent updates of MicroPython
- Media Interview: Qorvo Experts Talk About UWB
- Xi'an Datang Telecom_FPGA Experience
- What is the general speed of stm32 reading and writing TF?
- FPGA_100 Days Journey_DA Design
- How will 6 GHz and Matter change the smart home?
- Let’s discuss 5G millimeter wave technology and base station solutions.
- TE Connectivity enables electric vehicles with sensing and connectivity solutions