11
Training program: Mechanic - electrotechnician Program name: Digital processing - microprocessors III. class Microcontrollers Elaborated by: Vlastimil Vlček Projekt Anglicky v odborných předmětech, CZ.1.07/1.3.09/04.0002 je spolufinancován Evropským sociálním fondem a státním rozpočtem České republiky.

Anglicky v odborných předmětech "Support of teaching technical subjects in English “

Embed Size (px)

DESCRIPTION

Anglicky v odborných předmětech "Support of teaching technical subjects in English “. Training program: Mechanic - electrotechnician Program name : Digital processing - microprocessors III. class Microcontrollers Elaborated by: Vlastimil Vlček. - PowerPoint PPT Presentation

Citation preview

Training program: Mechanic - electrotechnician

Program name: Digital processing - microprocessorsIII. classMicrocontrollers

Elaborated by: Vlastimil Vlček

Projekt Anglicky v odborných předmětech, CZ.1.07/1.3.09/04.0002

je spolufinancován Evropským sociálním fondem a státním rozpočtem

České republiky.

Practical exercises

Task No. 3: Drat_3

Work procedure:

•Create a new source file and save it to the folder named “Drat_3” under the “Drat_3.asm” name.

Rewrite the source text from the supplied task printout to the editing window.

Check the finished source text and save it (rewrite the saved empty file).

Directives: #INCLUDE, BANKSEL Instructions: BTFSC, BTFSS, CALL, RETURN Testing of bit status by means of the BTS instruction Work with subroutines

Practical exercises

Task No. 3: Drat_3

Create a new project (use the procedure from chapter 11):

Project name: Drat_3.mcp, folder Drat_3.

Insert the source file Drat_3.asm.

Check and confirm the correctness of the assignment.

Save the project.

Practical exercises

Task No. 3: Drat_3

Connect the MPLAB ICD-2 debugger to the USB port of the computer.

Connect an instruction board (to the ICD-2) and connect the supply voltage of 9V to the instruction board.

Carry out the necessary setups and checks.

Translate the program (Ctrl F10), eliminate possible errors.

Practical exercises

Task No. 3: Drat_3

Launch the program (F9).

Check the correct function of the program:

Press any button on the instruction board (except the Reset button).

Check whether the corresponding LED diode is switched on when the button is pressed.

Try out how the program reacts when more buttons are pressed at the same time.

If the program does not work according to predictions, find the error by means of the procedures which were tried before and correct it.

Practical exercises

Task No. 3: Drat_3

By means of a step-by-step operation (F7, F8), go through the program line after line and watch the behaviour of the program in individual steps.

Focus on the BTFSS instruction and on the way how program branching is implemented.

Notice how the mechanism of subroutine calling and the return from a subroutine works.

Switch over to the MPLAB-SIM mode.

From the “View” menu, select “Hardware Stack”.

In “Stack”, watch how the system of return addresses works during subroutine calling and during the return (from a subroutine).

Practical exercises

A programmer´s nightmare – instructions BTFSS, BTFSC

Bit test of a selected register Skip of the following program line according to the test result

Summary of the subject matter - exercises

Have you noticed any change in the behaviour of the Drat_3 program in comparison with the Drat_1 and Drat_2 programs?

If so, are you able to explain its cause?

Find a proper change in the program listing and explain it!

Summary of the subject matter - exercises

Explain the function of this writing: #define TL1 PORTA,0.

What is the instruction for return from a subroutine?

Can the GOTO instruction be used for return from a subroutine in some cases?

What is so-called “return address”? Where is it saved?

Explain the function of the “STACK” register and the function of the return address system for subroutine calling and for the return from a subroutine.

Datasheet Microchip PIC16F882/883/884/886/887 DS41291E (http://www.microchip.com)

Microchip.com: Getting Started with PICmicro MCUs Microchip.com: MPLAB IDE User’s Guide Microchip.com: Quick Guide to Microchip Development Tools

References

Appendices

Appendix No. 3: Source text listing of the “Drat_3” program. Appendix No. 3, necessary to be translated in Notepad.