anglicky v odborných předmětech " support of teaching technical subjects in english“

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

Upload: tyra

Post on 06-Jan-2016

21 views

Category:

Documents


0 download

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

TRANSCRIPT

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

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.

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

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

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

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>

Program structure

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

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

Program structure

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

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 …

Program structure

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

An example of a subroutine:

;delay: delay loop

delay movlw '255'

movwf counter 1

decfsz counter 1

goto $-1

return

Program structure

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

An example of a table:

TAB RETLWb'11000000' ;character 0

RETLWb'11111001' ;character 1

RETLWb'10100100' ;character 2

RETLWb'10110000' ;character 3

RETLWb'10011001' ;character 4

RETLWb'10010010' ;character 5

RETLWb'10000010' ;character 6

RETLWb'11111000' ;character 7

RETLWb'10000000' ;character 8

RETLWb'10010000' ;character 9

RETLWb'10000110' ;character E

Program structure

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

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?

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

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.

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

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