Файл: The PIC Microcontroller Book for beginning (Nebojsa Matic).pdf
ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 15.06.2025
Просмотров: 1176
Скачиваний: 0
Chapter 5 - MPLAB
Welcome screen at the beginning of MPLAB installment
At the very beginning, it is necessary to select those MPLAB components we will be working with. Since we don't have any original Microchip hardware components such as programmers or emulators, we will only install MPLAB environment, Assembler, Simulator and the instructions.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_01Poglavlje.htm (3 of 10) [4/2/2003 16:18:18]
Chapter 5 - MPLAB
Selecting components of MPLAB developing environment
As it is assumed you will work in Windows 95 ( or a newer operating system), everything in connection with DOS operating system has been taken out during selection of assembler language. However, if you still wish to work in DOS, you need to deselect all options connected with Windows, and choose the components appropriate for DOS.
Selecting the assembler and the operating system
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_01Poglavlje.htm (4 of 10) [4/2/2003 16:18:18]
Chapter 5 - MPLAB
Like any other program, MPLAB should be installed into some directory. This option could be moved into any directory on any hard disc of your computer. If you didn't have a more pressing need, it should be left at selected place.
Choosing the directory where MPLAB will be installed
Users who have already had MPLAB (older version than this one) need the following option.
The purpose of this option is to save copies of all files which will be modified during a changeover to a new MPLAB version. In our case we should leave selected NO because of presumption that this is your first installment of MPLAB on your computer.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_01Poglavlje.htm (5 of 10) [4/2/2003 16:18:18]
Chapter 5 - MPLAB
Option for users who are installing a new version over an already installed MPLAB
Start menu is a group of program pointers, and is selected by clicking on START option in the lower left corner of the screen. Since MPLAB will be started from here, we need to leave this option as it is.
Adding the MPLAB to the start menu
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_01Poglavlje.htm (6 of 10) [4/2/2003 16:18:18]
Chapter 5 - MPLAB
Location that will be mentioned from here on, has to do with a part of MPLAB whose explanation we don't need to get into. By selecting a special directory , MPLAB will keep all files in connection with the linker in a separate directory.
Determining a directory for linker files
Every Windows program has system files usually stored in a directory containing Windows program. After a number of different installments, the Windows directory becomes overcrowded and too big. Thus, some programs allow for their system files to be kept in same directories with programs. MPLAB is an example of such program, and the bottom option should be selected.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_01Poglavlje.htm (7 of 10) [4/2/2003 16:18:18]
Chapter 5 - MPLAB
Selecting a directory for system files
After all of the above steps, installment begins by clicking on 'Next'.
Screen prior to installment
Installment doesn't take long, and the process of copying the files can be viewed on a small
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_01Poglavlje.htm (8 of 10) [4/2/2003 16:18:18]
Chapter 5 - MPLAB
window in the right corner of the screen.
Installment flow
After installment have been completed, there are two dialog screens, one for the last minute information regarding program versions and corrections, and the other is a welcome screen. If text files (Readme.txt) have opened, they would need to be closed.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_01Poglavlje.htm (9 of 10) [4/2/2003 16:18:18]
Chapter 5 - MPLAB
Last minute information regarding program versions and corrections.
By clicking on Finish, installment of MPLAB is finished.
Previous page |
Table of contents |
Chapter overview |
Next page |
© Copyright 1999. mikroElektronika. All Rights Reserved. For any comments contact webmaster.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_01Poglavlje.htm (10 of 10) [4/2/2003 16:18:18]
Chapter 5 - MPLAB
Previous page |
Table of contents |
Chapter overview |
Next page |
5.2 MPLAB
Following the installment procedure, you will get a screen of the program itself. As you can see, MPLAB looks like most of the Windows programs. Near working area there is a "menu" (upper blue colored area with options File, Edit..etc.), "toolbar" (an area with illustrations the size of small squares), and status line on the bottom of the window. There is a rule in Windows of taking some of the most frequently used program options and placing them below the menu, too. Thus we can access them easier and speed up the work. In other words, what you have in the toolbar you also have in the menu.
The screen after starting the MPLAB
The purpose of this chapter is for you to become familiar with MPLAB developing environment and with basic elements of MPLAB such as:
Choosing a developing mode
Designing a project
Designing a file for the original program
Writing an elementary program in assembler program language
Translating a program into executive code
Starting the program
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_02Poglavlje.htm (1 of 2) [4/2/2003 16:18:20]
Chapter 5 - MPLAB
Opening a new window for a simulator
Opening a new window for variables whose values we watch (Watch Window) Saving a window with variables whose values we are watching
Setting the break points in a simulator (Break point)
Preparing a program to be read in a microcontroller can boil down to several basic steps:
Previous page |
Table of contents |
Chapter overview |
Next page |
© Copyright 1999. mikroElektronika. All Rights Reserved. For any comments contact webmaster.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_02Poglavlje.htm (2 of 2) [4/2/2003 16:18:20]
Chapter 5 - MPLAB
Previous page |
Table of contents |
Chapter overview |
Next page |
5.3 Choosing the development mode
Setting a developing mode is necessary so that MPLAB can know what tools will be used to execute the written program. In our case, we need to set up the simulator as a tool that's being used. By clicking on OPTIONS---> DEVELOPMENT MODE, a new window will appear as in the picture below:
Setting a developing mode
We should select the 'MPLAB-SIM Simulator' option because that is where the program will be tried out. Beside this option, the 'Editor Only' option is also available. This option is used only if we want to write a program and by programmer write' hex file' in a microcontroller. Selection of the microcontroller model is done on the right hand side. Since this book is based on the PIC16F84, this model should be selected.
Usually when we start working with microcontrollers, we use a simulator. As the level of knowledge will have increased, program will be written in a microcontroller right after translation. Our advice is that you always use the simulator. Though program will seem to develop slower, it will pay off in the end.
Previous page |
Table of contents |
Chapter overview |
Next page |
© Copyright 1999. mikroElektronika. All Rights Reserved. For any comments contact webmaster.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_03Poglavlje.htm [4/2/2003 16:18:21]
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_04Poglavlje.htm |
|||
Previous page |
Table of contents |
Chapter overview |
Next page |
5.4 Designing a project
In order to start writing a program you need to create a project first. By clicking on PROJECT --> NEW PROJECT you are able to name your project and store it in a directory of your choice. In the picture below, a project named 'test.pjt' is being created and stored in c:\PIC\PROJEKTS\ directory.
This directory is chosen because authors had such directory set up of on their computer. Generally speaking, directory with files is usually placed in a larger directory whose name is unmistakably associated with its contents.
Opening a new project
After naming the project, click on OK. New window comes up as in the next picture.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_04Poglavlje.htm (1 of 4) [4/2/2003 16:18:24]
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_04Poglavlje.htm
Adjusting project elements
Using a mouse click on "test [.hex]" which activates 'Node properties' option in the bottom right corner of a window. By clicking on it you get the following window.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_04Poglavlje.htm (2 of 4) [4/2/2003 16:18:24]
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_04Poglavlje.htm
Defining parameters of MPASM assembler
From the picture we see that there are many different parameters. Each kind corresponds to one parameter in "Command line" . As memorizing these parameters is very uncomfortable, even forbidding for beginners, graphic adjustment has been introduced. From the picture we see which options need to be turned on. By clicking on OK we go back to previous window where "Add node" is an active option. By clicking on it we get the following window where we name our assembler program. Let's name it "Test.asm" since this is our first program in MPLAB.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_04Poglavlje.htm (3 of 4) [4/2/2003 16:18:24]
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_04Poglavlje.htm
Opening a new project
By clicking on OK we go back to the starting window where we see added an assembler file.
Assembler file added
By clicking on OK we return to MPLAB environment.
Previous page |
Table of contents |
Chapter overview |
Next page |
© Copyright 1999. mikroElektronika. All Rights Reserved. For any comments contact webmaster.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_04Poglavlje.htm (4 of 4) [4/2/2003 16:18:24]
Chapter 5 - MPLAB
Previous page |
Table of contents |
Chapter overview |
Next page |
5.5 Designing a new assembler file (writing a new program)
When "project" part of the work is finished, we need to start writing a program. In other words, new file must be opened, and will be named "test.asm". In our case, file has to be named "test.asm" because in projects which have only one file (such as ours), name of the project and name of the source file have to be the same.
New file is opened by clicking on FILE>NEW. Thus we get a text window inside MPLAB work space.
New assembler file opened
New window represents a file where program will be written. Since our assembler file has to be named "test.asm", we will name it so. Naming is done (as with all Windows programs) by clicking on FILE>SAVE AS. Then we get a window like the following picture.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_05Poglavlje.htm (1 of 2) [4/2/2003 16:18:26]
Chapter 5 - MPLAB
Naming and saving a new assembler file
When we get this window, we need to write 'test.asm' below 'File name:', and click on OK. After that, we will see 'test.asm' file name at the top of our window.
Previous page |
Table of contents |
Chapter overview |
Next page |
© Copyright 1999. mikroElektronika. All Rights Reserved. For any comments contact webmaster.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_05Poglavlje.htm (2 of 2) [4/2/2003 16:18:26]
Chapter 5 - MPLAB
Previous page |
Table of contents |
Chapter overview |
Next page |
5.6 Writing a program
Only after all of the preceding operations have been completed we are able to start writing a program. Since a simple program has already been written in "Assembly Language Programming" section of the book, so we will use that same program here, too.
Program has to be written to a window that's opened, or copied from a disc, or taken from MikroElektronika Internet presentation using options copy and paste. When the program is copied to "test.asm" window, we can use PROJECT -> BUILD ALL command (if there were no errors), and a new window would appear as in the next picture.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_06Poglavlje.htm (1 of 2) [4/2/2003 16:18:28]
Chapter 5 - MPLAB
Window with messages following a translation of assembler program
We can see from the picture that we get "test.hex" file as a result of translation process, that MPASMWIN program is used for translation, and that there is one message. In all that information, the last sentence in the window is the most important one because it shows whether translation was successful or not. 'Build completed successfully' is a message stating that translation was successful and that there were no errors.
In case an error shows up, we need to double click on error message in 'Build Results' window. This would automatically transfer you to assembler program and to the line where the error was.
Previous page |
Table of contents |
Chapter overview |
Next page |
© Copyright 1999. mikroElektronika. All Rights Reserved. For any comments contact webmaster.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_06Poglavlje.htm (2 of 2) [4/2/2003 16:18:28]