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“. Výukový program: Mechanik - elektrotechnik Název programu: Číslicová technika - mikroprocesory III. ročník Mikrořadiče Vypracoval : Vlastimil Vlček.

Télécharger la présentation

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

  2. 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)

  3. Work with subroutines Principle of a subroutine

  4. 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 loop wait_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

  5. Work with subroutines Instructions for working with subroutines CALL Subroutine calling RETURN 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!

  6. Work with subroutines Return address register (STACK)

  7. Work with subroutines Embedded subroutines

  8. 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?

  9. 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?

  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