110 likes | 166 Views
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.
E N D
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 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. 4: Running light 2 • Rotation of the register • Use of the Carry bit during the rotation • New instructions: RRF, RLF • Work procedure: • Create a new source file and save it to the folder named “BS_2” under the “BS_2.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).
Practical exercises Task No. 4: Running light 2 • Create a new project: • Project name: BS_2.mcp, folder BS_2. • Insert the source file BS_2.asm. • Check and confirm the correctness of the assignment. • Save the project.
Practical exercises Task No. 4: Running light 2 • 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. 4: Running light 2 • Launch the program (F9). • Check the correct function of the program: • The individual LED diodes are switched on gradually from LED 1 to LED 8 (the effect is unidirectional). • The speed of switching on of the LED diodes must be adapted so that the individual phases of switched on/ switched off can be perceptible by vision for certain. • 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. 4: Running light 2 • 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 activity of the rotation instruction and on the function of the Carry bit. • Try to change the speed of switching on and switching off of the LED diodes by means the change of the time constant of the delay loop.
Practical exercises Task No. 4: Running light 2 Rotation to the left (RLF) Rotation to the right (RRF)
Summary of the subject matter - exercises • Explain the principle of the rotation of a register! • How does the Carry bit participate in the rotation? • Is it possible to use the rotation of the register outside the Carry bit in the PIC16F883 microcontroller? • Which bit enters the Carry register as first during the rotation to the left (RLF)? • What happens to the original contentsof the Carry bit during rotation?
Summary of the subject matter - exercises • Give another use of the rotation of the register! • Do you remember a HW componentfrom digital processing which uses the principle of the rotation of the register? What is its practical use? • Homework: • Propose a procedure for the effect of a bidirectional running light with the use of the rotation instruction. • Modify the BS_2 program in such a way that the previous condition is fulfilled! • Debug the program in the MPLAB-IDE simulation mode with the use of presently known debugging means in such a way that the program can be used in the ICD-2 mode with an instruction board!
References • DatasheetMicrochip PIC16F882/883/884/886/887 DS41291E (http://www.microchip.com)
Appendices • Appendix No. 4: Source text listing of the “BS_2” program.