1 / 10

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.

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

  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'11101111‚ ;Setup of data downstream of the A port MOVWF TRISA MOVLW b'11111111‚ ;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 call zpozd ;timeout 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'11000000' ;character 0 RETLW b'11111001' ;character 1 RETLW b'10100100' ;character 2 RETLW b'10110000' ;character 3 RETLW b'10011001' ;character 4 RETLW b'10010010' ;character 5 RETLW b'10000010' ;character 6 RETLW b'11111000' ;character 7 RETLW b'10000000' ;character 8 RETLW b'10010000' ;character 9 RETLW b'10000110' ;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 • 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

More Related