Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Introduction to PIC Microcontrollers (Complete Guide to PIC).pdf
Скачиваний:
237
Добавлен:
12.08.2013
Размер:
1.88 Mб
Скачать

Chapter 5 - MPLAB

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 "proba.asm". In our case, file has to be named "proba.asm" because in projects which have only one file (such as ours), name of the project and name of the original 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.

http://www.mikroelektronika.co.yu/english/books/5_05Poglavlje.htm (1 of 2) [30/12/2001 16:54:09]

Chapter 5 - MPLAB

New assembler file opened

New window represents a file where program will be written. Since our assembler file has to be named "proba.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.

Naming and saving a new assembler file

When we get this window, we need to write 'proba.asm' below 'File name:', and click on OK. After that, we will see 'proba.asm' file name at the top of our window.

© Copyright 1999. mikroElektronika. All Rights Reserved. For any comments contact webmaster.

http://www.mikroelektronika.co.yu/english/books/5_05Poglavlje.htm (2 of 2) [30/12/2001 16:54:09]

Chapter 5 - MPLAB

5.6 Writing a program

Only after all of the preceding operations have been completed can we 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.

Chapter 5 - MPLAB

Program has to be copied 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 "proba.asm" window, we can use PROJECT -> BUILD ALL command (if there were no errors), and a new window will appear as in the next picture.

Window with messages following a translation of assembler program

We can see from the picture that we get "proba.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 will automatically transfers you to assembler program and to the line where the error is.

http://www.mikroelektronika.co.yu/english/books/5_06Poglavlje.htm (2 of 3) [30/12/2001 16:54:11]

Chapter 5 - MPLAB

© Copyright 1999. mikroElektronika. All Rights Reserved. For any comments contact webmaster.

http://www.mikroelektronika.co.yu/english/books/5_06Poglavlje.htm (3 of 3) [30/12/2001 16:54:11]