Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Projekt Anglicky v odborných předmětech, CZ.1.07/1.3.09/"— Presentation transcript:

1 Projekt Anglicky v odborných předmětech, CZ.1.07/1.3.09/04.0002
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/ je spolufinancován Evropským sociálním fondem a státním rozpočtem České republiky.

2 Program structure Definition: Initialization: Master program
Subroutines Tables Definition of Special function registers Definition of user registers and variables Setup of peripheral devices Setup of initial values of the ports Setup of data downstream through the ports Setup of initial values of user registers and variables Main program loop Subroutines used in the main program loop Tables of data constants, conversion tables, texts

3 Program structure An example of definitions: porta equ 0x05
portb equ 0x06 trisa equ 0x85 trisb equ 0x86 status equ 0x03 #define RP0 status,5 #define RP1 status,6  #define TL1 PORTA,0 #define TL2 PORTA,1 #INCLUDE <P16F883.INC>

4 Program structure An example of initialization: INIT NOP BANKSEL ANSEL ;Bank selection CLRF ANSEL ;PORTA = DIGITAL I/O BANKSEL TRISA MOVLW b' ‚ ;Setup of data downstream of the A port MOVWF TRISA MOVLW b' ‚ ;Setup of data downstream of the B port MOVWF TRISB MOVLW .0 ;Reset of the C port MOVWF TRISC BANKSEL PORTA RETURN

5 Program structure An example of a master program: START CALL INIT ;initialization of the microcontroller bsf VYSTUP ;H level on the OUTPUT bit call zpozd ;timeout bcf VYSTUP ;L level on the OUTPUT bit goto START ;and again from the beginning …

6 Program structure An example of a subroutine: ;delay: delay loop delay movlw '255' movwf counter 1 decfsz counter 1 goto $-1 return

7 Program structure An example of a table: TAB RETLW b' ' ;character 0 RETLW b' ' ;character 1 RETLW b' ' ;character 2 RETLW b' ' ;character 3 RETLW b' ' ;character 4 RETLW b' ' ;character 5 RETLW b' ' ;character 6 RETLW b' ' ;character 7 RETLW b' ' ;character 8 RETLW b' ' ;character 9 RETLW b' ' ;character E

8 Summary of the subject matter - exercises
What is the difference between a definition and a declaration? What is a peripheral device in a microcontroller? Why is it good to set up the initial vaules of the ports before we set up the data downstream in them? Why do we have to work with so-called banks? Which part of the memory of a microcontroller do they concern?

9 Summary of the subject matter - exercises
What are the advantages and pitfalls of the use of the #define directive? What is the main principle of creating a master program? What is the purpose and sense of a subroutine, how is it called and how is it used? Give an example of the use of a delay loop. Give an example of the use of a table of constants.

10 References Datasheet Microchip PIC16F882/883/884/886/887 DS41291E ( Microchip.com: Getting Started with PICmicro MCUs Microchip.com: MPLAB IDE User’s Guide Microchip.com: Quick Guide to Microchip Development Tools


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

Similar presentations


Ads by Google