Les 3 - onderwerpen
description
Transcript of Les 3 - onderwerpen
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
12PROJ5 – PIC assembler
Les 3 - onderwerpen
DB036 printjes
• subroutines• Een programma voor de DB036• gebruik van PICkit 2 tool• opgaven: LED tellen; Kitt display
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
22PROJ5 – PIC assembler
Printjes – neem:
• Een doos (succes met vouwen)• Het printje• 5 rubber voetjes
(zie onderkant, eerst even schoonvegen)• Twee vellen schuimrubber voor in de doos• Twee USB kabels• Een headset
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
32PROJ5 – PIC assembler
subroutine voorbeeld
wait
addlw 0
skpz
return
addlw 1
goto wait
...
...
movlw D’200’
call wait
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
42PROJ5 – PIC assembler
subroutine
• lijkt op een C/Java/C# functie maar veel primitiever
• label waar je met een call instructie heen springt
• daar een reeks instructies
• een return instructie brengt je terug
• er is een stack voor de return adressen
• die stack is maar 8 niveau’s diep
• volgorde van subroutines en main is niet belangrijk
• let wel op als je subroutines vooraan staan!
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
52PROJ5 – PIC assembler
Een DB036 programma (1);================================================================; ; walk;;================================================================
; initialisation etc for DB036#include <DB036-01.INC>
;================================================================; initialisatie;================================================================
CBLOCKPatternDelayCounter1, DelayCounter2
ENDC
MOVLW 0x80MOVWF Pattern
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
62PROJ5 – PIC assembler
Een DB036 programma (2)
;================================================================; main loop;================================================================
MainLoopCLRCRLF Pattern, fMOVF Pattern, FMOVLW 0x05SKPNZ
MOVWF PatternMOVFW PatternXORLW 0xFFMOVWF PORTD
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
72PROJ5 – PIC assembler
Een DB036 programma (3)
CLRF DelayCounter1
DelayLoop1
CLRF DelayCounter2
DelayLoop2
CALL SmallDelay
DECFSZ DelayCounter2, f
GOTO DelayLoop2
DECFSZ DelayCounter1, f
GOTO DelayLoop1
GOTO MainLoop
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
82PROJ5 – PIC assembler
Een DB036 programma (4)SmallDelay
CALL SmallDelayReturn
SmallDelayReturn
RETURN
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
92PROJ5 – PIC assembler
PICkit 2 V1.20
• Gebruik V1.20
• Device Family > Midrange (14 bit core)
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
102PROJ5 – PIC assembler
PICkit 2 V1.20
• Selecteer de .hex file die je in MPLAB hebt aangemaakt: <project name>.HEX
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
112PROJ5 – PIC assembler
PICkit 2 V1.20
• Zet target 5.0V aan
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
122PROJ5 – PIC assembler
PICkit 2 V1.20
• Zet programmeren van de Data EEPROM (voorlopig) uit
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
132PROJ5 – PIC assembler
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
142PROJ5 – PIC assembler
DB036 bordje – tel op 8 LEDs
Main loop:– Tel in een variabele– Copieer die naar PORTD– Wacht 2 ms (gebruik je wacht subroutine)
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
152PROJ5 – PIC assembler
DB036 bordje – Kitt Display
Maakt een ‘Kitt’ display op de 8 LEDs. (Kitt patroon is: 1 LED aan, beweegt heen-en-weer). NB: 2 ms voor een stap is nu een beetje te snel!