ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 12.06.2025

Просмотров: 1359

Скачиваний: 3

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

Basic for PIC Microcontrollers

148

The screen exactly before the installation

The installation itself is brief and the course of the copying can be monitored on the small screen in the right corner.

The installation in course

When the installation is terminated, two dialog boxes are present on the screen – one for the last information concerning corrections and the version of the program, the other greeting one. If the text files (Readme.txt) are opened they should be closed.

Basic for PIC Microcontrollers

149

The last information concerning version and the corrections on the program

By clicking on the Finish button the installation of the program is thereby terminated.

A.2 Connection of PIC BASIC and MPLAB

To make work as easy as possible to those who already got used to the assembler’s compiler and MPLAB, Microchip has left the option of using, besides its proper, the compilers of the other manufacturers in its MPLAB development tool. Before starting to write a program, it is necessary to undertake some adjustments. Let's assume that, for example MPLAB is installed in directory: C:\ Program Files \ MPLAB and PIC BASIC Pro compiler in C:\ PBP.

You just start the MPLAB and choose Install Language Tool from the Project menu. The dialog box where the corresponding options is to be set, the manufacturer first, (whereby directly in the next option comes the list of compilers by the same manufacturer) and accordingly the compiler itself – in our case Pic Basic Pro Compiler- and exactly as the one on the pict ure bellow will appear then. At the end on should click at the option “browse” and find PBP.EXE file on the disk (in this case C: PBP \). By clicking on OK the basic settings are completed.

Basic for PIC Microcontrollers

150

Start MPLAB and choose the Install Language Toolfrom the Project menu.

Next step is the creation of the project that is done in a standard way by selecting New Project from the Project menu and by assigning the project name e.g. “probe.pjt”. A special care is to be given to the project storage location. The new project and all its components must be located in the same directory as PicBasic Pro! For this case, the project must be stored in C:/PBP.

Creating project by selecting New Project from Project menu and assigning the project name as, e.g. “probe.pjt”.

By clicking OK the new window Edit Project appears. In Language Tool “microEngeneering Labs” is to be selected (answer the incoming question with OK). It is, hence, necessary to click on ‘probe [.hex]’ in the lower part of the window whereby the option Node Properties is activated.


Basic for PIC Microcontrollers

151

The New window Edit Project for the definition of the manufacturer. Choose “microEngeneering Labs”

The purpose oh this window is to set the microcontroller for which the program is written.

By clicking Change button, the new window for choosing the available microcontrollers appears. As an option, Editor only is to be left in the absence of any available Microchip’s tools (this option states the use of MPLAB as a shell for PIC Basic compiler).

Bu clicking Node Properties the window shown on the picture below appears. Choose "PM" version in the assembler selection. Clicking the OK returns us to the previous window.

Basic for PIC Microcontrollers

152

The Add Node button is active now, and through it the name to the file with basic program is assigned. It is in our case, ‘probe.bas’. it is to take notice that the present action is only assigning name of the file into the project. Its actual creation is done in next step.

Window for naming the program in writing. Opening of the file is done in next step.

Basic for PIC Microcontrollers

153

So far we defined microcontroller and the programming language. It still remains to open the file, write the code and register it under the name given in previous step. (proba.bas).

By clicking File-> New the window in which the basic program will be written appears.

Before we start the program writing, file must be registered with the command File -> Save as, file name being obviously “proba.bas”. The code writing can start now. The program here serving as an example is a very simple one and its only function is to make the diode on a port B twinkle.

The window for writing Basic program

Upon finishing the code writing, the click on PROJECT-> Build All is performing the compilation of the program. Unless there have been some errors, the obtained file is C:/PBP/probe.hex readable into the microcontroller.

Basic for PIC Microcontrollers

154

A.3 Toolbar

Since MPLAB is composed of several separate parts, each of them possesses its own toolbar. However, there exists a toolbar being a sort of a combination of all the others, which may be considered as a common one. This toolbar is sufficient for our needs so it will be the explained in details. On the picture bellow this toolbar is given with the brief explanations of the icons. Out of the limited format of this book, the basic toolbar is displayed as the free one and in a standard position is always bellow the menu, displaced horizontally along the entire screen.

If, for whatever reason, currently used toolbar does not respond, upon clicking this icon the next toolbar becomes available. The change goes into circle so that upon the 4th click, the same toolbar is obtained again.

If the current toolbar for some reason does not respond to a click on this icon, the next one appears. Changeover is repeated so that on the fourth click we will get the same toolbar again.

Icon for opening a project. Project opened in this way contains all screen adjustments and adjustment


Basic for PIC Microcontrollers

155

Icon for saving a project. Saved project will keep all window adjustments and all parameter adjustmen When we read in a program again, everything will return to the screen as when the project was closed

Searching for a part of the program, or words is operation we need when searching through bigger ass or other programs. By using it, we can find quickly a part of the program, label, macro, etc.

Cutting a part of the text out. This one and the following three icons are standard in all programs that with processing textual files. Since each program is actually a common text file, those operations are u

Copying a part of the text. There is a difference between this one and the previous icon. With cut oper when you cut a part of the text out, it disappears from the screen (and from a program) and is copied afterwards. But with copy operation, text is copied but not cut out, and it remains on the screen.

When a part of the text is copied, it is moved into a part of the memory which serves for transferring d Windows operational system. Later, by clicking on this icon it can be 'pasted' in the text where the cur

Saving a program (assembler file).

Start program execution in full speed. It is recognized by appearance of a yellow status line. With this program execution, simulator executes a program in full speed until it is interrupted by clicking on the traffic light icon.

Stop program execution in full speed. After clicking on this icon, status line becomes gray again, and p execution can continue step by step.

Step by step program execution. By clicking on this icon, we begin executing an instruction from the n program line in relation to the current one.

Skip requirements. Since simulator is still a software simulation of real work, it is possible to simply sk some program requirements. This is especially handy with instructions which are waiting for some requirement following which program can proceed further. That part of the program which follows a requirement is the part that 's interesting to a programmer.

Resetting a microcontroller. By clicking on this icon, program counter is positioned at the beginning of program and simulation can start.

By clicking on this icon we get a window with a program, but this time as program memory where we which instruction is found at which address.

With the help of this icon we get a window with the contents of RAM memory of a microcontroller.

By clicking on this icon, window with SFR register appears. Since SFR registers are used in every progr is recommended that in simulator this window is always active.

If a program contains variables whose values we need to keep track of (ex. counter), a window needs added for each of them, which is done by using this icon.

When certain errors in a program are noticed during simulation process, program has to be corrected. simulator uses HEX file as its input, so we need to translate a program again so that all changes would transferred to a simulator. By clicking on this icon, entire project is translated again, and we get the n version of HEX file for the simulator.

Basic for PIC Microcontrollers

156

Appendix B

MicroCODE STUDIO

Introduction

B.1 Installation of the PIC Basic Pro compiler

B.2 Installation of a MicroCODE studio

B.3 Connecting MicroCODE Studio and PBP compiler

B.4 Connecting MicroCODE Studio and the programmer

B.5 Code writing and compilation in MicroCODE studio

Introduction

Although the code writing can be done with the simplest editor and compiled in command line (those who had programmed in DOS probably remember well those acrobatics) using special “editors” appropriate for programming language is far better.

Such specialized editors are called “Integrated Development Environments” - IDE. Using them makes code writing easier as the programmer is able to supervise which variables, labels or similar program elements have already been used. At the same time, they make command words bold and even write them in another color rendering thereby program more intelligible. The option for automatic call up of the programmer is also available together with many other facilities. Simply put, having those facilities without using them is like climbing on foot to the 13th floor of a building with elevator.

B.1 Installation of the PIC Basic Pro compiler

The first thing to be done is to create a new directory into which the compiler will stored. Let it be the directory C:/PBP. Then follows the copying of data file PBP240.EXE into that directory and its unpacking (compiler enters in the form of unpacking archive)? by double-clicking it. Unless the compiler is unpacked it is enough to copy it into the desired directory.

B.2 Installation of a MicroCODE studio

Installation of the editor starts by double-clicking on MCSTUDIO. Afterwards, the standard setup process is started where the computer location for the editor’s installationcan be chosen. The setup process starts with the usual warning to close all other active windows. By clicking on button Next, the setup continues.


Basic for PIC Microcontrollers

157

The first window after the installation starts. It is necessary to click on button Next

Next question is whether you accept the license and copyright rules or not. By accepting these rules by clicking on the Yes button, the installation goes forward. The next image corresponds to that phase of the installation.

Basic for PIC Microcontrollers

158

The directory for editor location is the next question. In case of failed statement of the directory, the installation is to be effectuated in C:\ProgramFiles\Mecaniqe.

The choice of an installation directory. The best choice is to leave the option by default. It is necessary to click on OK button in order to proceed

Basic for PIC Microcontrollers

159

The name and address of directory is without any special meaning for further programming. The real issue is the available memory space on the hard disk or on the need for keeping all items associated with a single program in the same directory.

The next question refers to the name of programming group. The name already offered corresponds to the program name so it should be left as such.

The program group is to be named MicroCodeStudio. Clicking on Next, the installation goes on

Finally, the window appears confirming the successfully performed installation.

Basic for PIC Microcontrollers

160

B.3 Connecting MicroCODE Studio and PBP compiler

Clicking on Start-Programs-MicroCode Studio starts up the just installed MicroCode Studio and the window from the picture bellow will appear.


Basic for PIC Microcontrollers

161

To connect MicroCode Studio and PBP compiler a new window is to be opened. It’s done by clicking on the Options from the View menu. If the compiler is already copied into a hard disk directory clicking on the Find Automatically button whereupon will the program itself search for the directory with compiler through the hard disk. When the program finds the compiler, above the button the path “C:\PBP” will appear above the button

Find Automatically.

Basic for PIC Microcontrollers

162

Connecting MicroCode studio and PBP compiler. If the PBP compiler is already copied into a directory on a hard disk, it is enough to click on the Find Automatically button and the program will find it on its own

Beside the path to the compiler, it is still necessary to define the path to the include data file. By clicking on Add the paths C:/PBP and C:/PBP/inc are added within Includes.

Basic for PIC Microcontrollers

163

Include data files are necessary for successful compilation of the program. Clicking the Add, the new window appears with theinc directory into which the PBP compiler is copied

Basic for PIC Microcontrollers

164

Options window after setting the path to the compiler andinclude data files. Notice that there areinclude data files in the very C: \PBP directory so that their path should be specified as well

This step finishes the setting part referring to the compiler. MicroCode studio is now ready for program reading and compiling.

B.4 Connecting MicroCODE Studio and the programmer

The installation of the programmer that MicroCode will call upon successfully accomplished program compilation is to be undertaken only if the user possesses some development environment or some of the programmers that will read in the comp iled program into the microcontroller. In lack of any of these tools this part of MicroCode studio setting is to be omitted.

The setting of the programmer starts by clicking on Programmers whereupon two distinct options appear, one for adding of programmer into the list and another for their removal. The programmer that is to be used here

Basic for PIC Microcontrollers

165

ranks as the simplest economic programmers of PIC microcontrollers that are available at the moment. The name of this programmer is ICprog and it uses the serial pin of the computers port in order to communicate with the microcontroller (more details can be found in the special appendix contained in this book).

By clicking Programmers the part for setting the programmer appears

Before installing the programmer, it has to be copied in a directory on the hard disc, e.g. “C:\Programmer”. Clicking the “Add new Programmer…”, the brief procedure of selecting the path to programmer begins.

The first step is writing the name of the programmer or any abbreviation that could bear resemblance to it. As Icprog programmer is used it is logical to name it “ICprog”.