1 / 11

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

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.

Download Presentation

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

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Anglicky v odborných předmětech"Support ofteachingtechnicalsubjects in English“ 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.

  2. Practical exercises Task No. 3: Drat_3 • Directives: #INCLUDE, BANKSEL • Instructions: BTFSC, BTFSS, CALL, RETURN • Testing of bit status by means of the BTS instruction • Work with subroutines • 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).

  3. 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.

  4. 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.

  5. 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.

  6. 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).

  7. 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

  8. 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!

  9. 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.

  10. References • DatasheetMicrochip PIC16F882/883/884/886/887 DS41291E (http://www.microchip.com) • Microchip.com: GettingStartedwithPICmicroMCUs • Microchip.com: MPLAB IDE User’s Guide • Microchip.com: QuickGuide to MicrochipDevelopmentTools

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

More Related