De presentatie wordt gedownload. Even geduld aub

De presentatie wordt gedownload. Even geduld aub

2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 1 Les 2 - onderwerpen  Helaas nog geen printjes.

Verwante presentaties


Presentatie over: "2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 1 Les 2 - onderwerpen  Helaas nog geen printjes."— Transcript van de presentatie:

1 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 1 Les 2 - onderwerpen  Helaas nog geen printjes Uitwerking opgaven 1 en 2 Herhaling instructieset Assembler ‘truukjes’ MPLAB Simuleren Opgaven: delay W ms, jumptable

2 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 2 oefening 1 : optellen ; tel de variabelen H'20' en H'21' op, ; stop de som in H'22' movf H'20', w addwf H'21', w movwf H'22' sleep ; zet dit na je code end; zet dit aan het einde van je file

3 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 3 SUBWF instruction (1)

4 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 4 SUBWF instruction (2)

5 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 5 oefening 2 : maximum (1) ; bepaal het maximum van de variabelen H'20' en H'21' ; stop dit maximum in H'22‘(9 instructies) ; vergelijk movfw H'20' subwf H'21', w; H’21’ – H’20’ skpnc; C  resultaat is positief  H’22’ is kleiner goto kleiner; C  neem H’21’ ; als we hier komen was H'20' dus groter movfw H'20' movwf H'22' goto klaar ; als we hier komen was H'21' groter kleiner movfw H'21' movwf H'22' klaar

6 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 6 oefening 2 : maximum (2) ; dat kan ook wat korter (6 instructies) ; neem aan dat H'20' het maximum is movf H'20', w movwf H'22' ; vergelijk met H'21' ; movfw H'20' is niet nodig, dat zit al in W subwf H'21', w ; dit beinvloedt de C flag niet!!! movf H'21', w skpnc movfw H'22'

7 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 7 oefening 2 : maximum (3) ; of zo (ook 6 instructies) ; vergelijk movfw H'20' subwf H'21', w ; dit beinvloed de flags niet!!! movf H'20', w skpnc movf H'21', w movwf H'22'

8 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 8 Instructies: file + w => file of w

9 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 9 Instructies: bit set/clear, bit test

10 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 10 Instructies: file ‘op’ literal => file of w, diversen (control)

11 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 11 Assembler “truukjes” Ingebouwd: SKPZ, SKPNZ, SKPC, SKPNC STEC, CLRC, SETZ, CLRZ MOVFW Macro’s: #define W 0 #define F 1 Let op mogelijke fouten, wat doet: RRC W, F

12 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 12 Meer assembler “truukjes”

13 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 13 MPLAB IDE IDE : Integrated Development Environment Project management Editor Assembler Programmer/debugger interface(s) Integration of third-party tools (compilers)

14 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 14 Gebruik van MPLAB (Zie ook de MPLAB quick start guide op de Microchip website ) Start MPLAB Controleer: Configure  Select Device  16F917 Start een project: Project  New  kies een project naam, zet project directory naar keuze lokaal, op je USB stick, of op (in directory in) je network drive (heel erg lange pad-namen kunnen problemen geven) Of open een bestaand project: Project  Open  kies een bestaand project Een nieuwe file creeren: File  New; File  Save As  mag zelfde naam als project (als het de hoofdfile is, of als je maar 1 file gebruikt) Een assembler file toevoegen aan een project: Project  Add Files to Project  double click to add the file as source file

15 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 15 Gebruik van de assembler Check: edit  properties  editor tab  zet “line numbers’ aan Edit je file (saven is niet nodig maar wel verstandig) Assembleren en linken: Project  Build All Herhalen tot de fouten en warnings eruit zijn!

16 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 16 Gebruik van de simulator Debugger  select tool  MPLAB SIM Debugger  reset  processor reset (F6) Debugger  Clear Memory  GPRs (let op!) Debugger  step into (F7) View  4 File Registers View  5 Special Function Registers (Waarden die in de vorige stap zijn veranderd worden rood weergegeven.)

17 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 17 Gebruik van de simulator Stap nu een aantal keren tot je denkt dat je programma-lus goed werkt (F6) Double-click op de regel na een loop om een breakpoint te zetten Debugger  Run (F9) Controleer of het resultaat klopt

18 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 18 Doen  test je ‘vermenigvuldig’ programma in de simulator

19 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 19 PIC16F917 memory map

20 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 20 Assembler : variabelen Absolute adressen: Met #define of EQU: movfw H’20’ movwf H’21 #define A H’20’ BEQU H’21’ movfw A movwf B

21 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 21 Assembler : variabelen cblock cblock 0x20 name_1, name_2 name_3, name_4 endc... cblock name_5 name_6 : 2 endc

22 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 22 Assembler template (zie website) list p=16f917, f=inhx32 #include org 0 cblock H’20’ endc ; hier komt uw code sleep END

23 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 23 Een stukje van PIC16F917.INC ;----- Register Files----------------------------- INDF EQU H'0000' TMR0 EQU H'0001' PCL EQU H'0002' STATUS EQU H'0003' FSR EQU H'0004' PORTA EQU H'0005' PORTC EQU H'0007' PCLATH EQU H'000A' INTCON EQU H'000B' PIR1 EQU H'000C' Staat op C:/Program Files/MPLAB IDE/MChIP_Tools

24 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 24 Programmeren 1: Een delay subroutine Een instructie duurt 0.2 us (20 MHz, 5 MIPS) Een ‘geskipte’ instructie ook! Behalve GOTO, CALL, RETURN: 0.4 us  Maak een subroutine die W ms wacht Test dmv de stopwatch/instructie counter

25 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 25 PC manipulatie PCL is de laagste 8 bits van de program counter (PC) Maar: schrijven naar PCL schrijft die waarde naar PC[0..7], en PCLATH naar PC[8..] Hiermee kan je een jumptable maken: spring naar een plek N plaatsen verder Nuttig in combinatie met RETLW X

26 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 26 PC manipulatie

27 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 27 Programmeren 2: Een jump table Maak een subroutine die afhankelijk van de waarde in W bij de aanroep een waarde in W teruggeeft: 0  0 1  1 2  4 3  9 … 9  81 Boven 9 is het effect niet gedefinieerd; neem aan dat de waarde in PCLATH in order is  Maak een overtuigende test!


Download ppt "2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 1 Les 2 - onderwerpen  Helaas nog geen printjes."

Verwante presentaties


Ads door Google