+ All Categories
Home > Documents > 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“

Date post: 31-Dec-2015
Category:
Upload: lillian-underwood
View: 8 times
Download: 1 times
Share this document with a friend
Description:
Anglicky v odborných předmětech " Support of teaching technical subjects in English“. Výukový program: Mechanik - elektrotechnik Název programu: Číslicová technika - mikroprocesory III. ročník Mikrořadiče Vypracoval : Vlastimil Vlček. - PowerPoint PPT Presentation
10
Výukový program: Mechanik - elektrotechnik Název programu: Číslicová technika - mikroprocesory III. ročník Mikrořadiče Vypracoval: 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.
Transcript

Výukový program: Mechanik - elektrotechnik

Název programu: Číslicová technika - mikroprocesoryIII. ročníkMikrořadiče

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

Work with subroutines

Why to use subroutines?

• They increase the clarity of the whole program

• They save place in the memory (they replace repeating parts of a program)

• They support methodicalness of work (by means of creating subroutine libraries)

• They save a programmer´s time (thanks to using subroutine libraries)

• They enable the use of subroutine libraries by other programmers (Internet)

Work with subroutines

Principle of a subroutine

Work with subroutines

An example of using a subroutine

start1 bcf LED1 ;switch on LED1 call wait ;wait 80ms bsf LED1 ; switch off LED1 call wait ; wait 80ms  bcf LED2 ;switch on LED2 call wait ;wait 80ms bsf LED2 ; switch off LED call wait ; wait 80ms

wait movlw .255 ;subroutine beginning movwf counter_1 ;outer loopwait_A movlw .255 movwf counter_2 ;inner loop decfsz counter_2,f ;readout of the inner loop counter, zero test goto $-1 ;is not zero - back decfsz counter_1,f ;readout of the outer loop counter,

;zero test goto wait_A ;is not zero - back nop return ;both loops are reset - return

Work with subroutines

Instructions for working with subroutines

CALL Subroutine callingRETURN Return from a subroutine

(Use: common subroutines)

RETLW Return from a subroutine with a constant in the W register(Use: work with tables)

RETFIE Return from an interruption subroutine(Use: interruption system)

Each CALL instruction must correspond to a RETURN (RETLW, RETFIE) instruction. Not keeping this condition leads to the violation of the system of return address register and to the program crash!

Work with subroutines

Return address register (STACK)

Work with subroutines

Embedded subroutines

Summary of the subject matter - exercises

When is it advantageous to use subroutines?

What are the principles of writing subroutines?

What are the advantages of creating subroutine libraries?

Are subroutines portable between different types of microcontrollers? What does this portability depend on?

Summary of the subject matter - exercises

What is the relationship of the CALL instruction to the RETURN instruction?

What are “embedded” subroutines?

What function does the return address register have in a microcontroller?

How does so-called “overflow” of the return address stack originate and what are the consequences of this?

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


Recommended