The University Of Texas At Arlington Lecture 3 PIC .

3y ago
10 Views
3 Downloads
1.11 MB
37 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Jerry Bolanos
Transcription

The University of Texas at ArlingtonLecture 3PIC Assembly BasicsCSE 3442/5442Embedded Systems IBased heavily on slides by Dr. Roger Walker

From Last Lecture Download MPLAB and C18 Link for MPLAB vice SS GET PAGE&nodeId 1406&dDocName en019469&part SW007002 Link for rvice SS GET PAGE&nodeId 1406&dDocName en0100142

Installation of Assembler/CCompiler http://www.microdigitaled.com/PIC/PIC books.htm LABInstall.pdf for installing tall.pdf for installing C18 pdf for MPLAB Tutorial3

Compiler Data Formats Data Types - hex, decimal, binary, ASCII Hex:– Use h (or H) right after the number: MOVLW 99H– Put 0x (or 0X) in front of the number: MOVLW 0x99H– Put nothing in front or back of the number: MOVLW99– Put h in front of the number, with single quotesaround the number: MOVLW h’99’4

Compiler Data Formats Binary:– Put B in front of the number in single quotes: MOVLW B’10011001’ Decimal:– Put D in front of the number in single quotes: MOVLW D’12’– Use .value: MOVLW .125

Compiler Directives Compiler directives: give directions to thecompiler.– EQU (defining constants), (SET is similar but can bereset) DATA1 EQU 39H - Data assignment PORTB EQU 0xFF6 – SFR address assignment MYREG EQU 0x12 – RAM address assignment– ORG (origin - explicit address offset operand must behex)– END (tells assembler that this is end of code)6

Compiler Directives LIST (indicates specific controller, e.g.,LIST P 18F452) unique to PIC assembler. #include (to include libraries associated) config directives – tell assembler whatthe configuration (stored at 300000H) bitsof the target PIC should be radix (e.g., radix dec will change todecimal notation; default is hex)7

Configuration RegistersTable 19-1 from Data Sheet8

Assembly LanguageInstruction Assembly Language instruction containsfour fields:– Label– Mnemonic– Operands– Comments[label] mnemonics [operands] [;comments]9

Assembly ProgrammingsampleSUMHEREEQU10H; RAM loc 10H for SUMORG0H; start at address 0MOVLW 25H;25H à WREGADDLW 0x34; 34HADDLW 11H; 11HADDLW 25; 25HADDLW D'18‘ ; 18 decimalADDLW .18; 18 decimalADDLW A’0’; add ascii of 0 (32)ADDLW B'00000110‘; 6MOVWF SUMGOTO HEREENDFrom page 6910

Assembly Assembled an LinkedFigure 2-8.11

Files Used and Created .hex à PIC ROM (loadable object).mcp : MPLAB Project mcp.mcw: MPLAB Workspace.cod Code Listing.lst Program listing (machine code with assemblycomments) .map a file containing memory layout of usedand unused locations .o immediate object .err Debug information12

PIC18 Program Counter2 MBFigure 2-9.13

PIC18 On-Chip Program ROMAddress Range4k16 k32 k(452)Figure 2-1014

PIC18F458 Pin Diagram15

Example - Powering UpPIC18F45816

Programs in ROM When PIC is powered up (VCC applied toReset Pin – Chapter 8), the microcontroller begins executing instruction atlocation 00000h (Reset Vector). Use ORG statement for this instruction inyour code (if programming in assembly). Ccompiler takes care of creating assemblycode having this.17

PIC18 Program ROM Width18

PIC18 Program ROM Contentsfor Program 2-1 List FileMemory is structured in ‘little endian’ mode(lowest value at lowest address)Program 2-1 List19

GOTO and the PC GOTO, 4 byte instruction:0E070FEF100011F0little endian!PCU0 0 0 k19PCHk15 k14PCLk 7 k621 bit PCk0 020

PIC uses Harvard Architecture21

RISC1. Fixed instruction size (2 and 4 bytes in PIC ;ADD, GOTO)2. Many registers (no need for large stack)3. Small instruction set – longer code4. Small clock cycle/instruction5. Usually Harvard architecture6. No microcoding; instructions are internallyhardwired – can result in 50% reduction in thenumber of transistors7. No cross operations between GFR registers22

MPLAB Simple Assembly Sample Create projectType in codeSet debugger to simulatorAdd watch windowsLook at what is happening23

24

25

26

27

28

29

30

CSE 3442/4442 Lecture 3Dr. Roger Walker31

Special File Register Windowin MPLAB Simulator32

File Register (Data RAM) Windowin MPLAB Simulator33

Program (Code) ROM Window inMPLAB Simulator34

QwikFlash Board Information on QwikFlash Board at http://www.picbook.com/CSE 3442/4442 Lecture 3Dr. Roger Walker35

Assignment for Next Class Review the material in Chapter 3. Pay close attention to the instruction word sizesand target address for the BRA, GOTO, andCALL instructions, and for the Stackimplementation. Using the MPLAB assembler and simulator,code and run the example on page 115(Example 3-11), adding appropriate break pointsfor using the simulator to display the stackcontents after one of the call examples.36

PIC Data Sheets Note, the iceDoc/39564c.pdf iceDoc/41159e.pdf37

Compiler Data Formats Data Types - hex, decimal, binary, ASCII Hex: – Use h (or H) right after the number: MOVLW 99H – Put 0x (or 0X) in front of the number: MOVLW 0x99H – Put nothing in front or back of the number: MOVLW 99 – Put h in front of the number, with single quotes around the number: MOVLW h’99’ 4

Related Documents:

May 02, 2018 · D. Program Evaluation ͟The organization has provided a description of the framework for how each program will be evaluated. The framework should include all the elements below: ͟The evaluation methods are cost-effective for the organization ͟Quantitative and qualitative data is being collected (at Basics tier, data collection must have begun)

Silat is a combative art of self-defense and survival rooted from Matay archipelago. It was traced at thé early of Langkasuka Kingdom (2nd century CE) till thé reign of Melaka (Malaysia) Sultanate era (13th century). Silat has now evolved to become part of social culture and tradition with thé appearance of a fine physical and spiritual .

On an exceptional basis, Member States may request UNESCO to provide thé candidates with access to thé platform so they can complète thé form by themselves. Thèse requests must be addressed to esd rize unesco. or by 15 A ril 2021 UNESCO will provide thé nomineewith accessto thé platform via their émail address.

̶The leading indicator of employee engagement is based on the quality of the relationship between employee and supervisor Empower your managers! ̶Help them understand the impact on the organization ̶Share important changes, plan options, tasks, and deadlines ̶Provide key messages and talking points ̶Prepare them to answer employee questions

Dr. Sunita Bharatwal** Dr. Pawan Garga*** Abstract Customer satisfaction is derived from thè functionalities and values, a product or Service can provide. The current study aims to segregate thè dimensions of ordine Service quality and gather insights on its impact on web shopping. The trends of purchases have

Chính Văn.- Còn đức Thế tôn thì tuệ giác cực kỳ trong sạch 8: hiện hành bất nhị 9, đạt đến vô tướng 10, đứng vào chỗ đứng của các đức Thế tôn 11, thể hiện tính bình đẳng của các Ngài, đến chỗ không còn chướng ngại 12, giáo pháp không thể khuynh đảo, tâm thức không bị cản trở, cái được

Le genou de Lucy. Odile Jacob. 1999. Coppens Y. Pré-textes. L’homme préhistorique en morceaux. Eds Odile Jacob. 2011. Costentin J., Delaveau P. Café, thé, chocolat, les bons effets sur le cerveau et pour le corps. Editions Odile Jacob. 2010. Crawford M., Marsh D. The driving force : food in human evolution and the future.

Le genou de Lucy. Odile Jacob. 1999. Coppens Y. Pré-textes. L’homme préhistorique en morceaux. Eds Odile Jacob. 2011. Costentin J., Delaveau P. Café, thé, chocolat, les bons effets sur le cerveau et pour le corps. Editions Odile Jacob. 2010. 3 Crawford M., Marsh D. The driving force : food in human evolution and the future.