This preview shows page 1-2-3-22-23-24-44-45-46 out of 46 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Microcontroller (?C) vs. Microprocessor (?P)PIC18Fxx2 ?CPIC18Fxx2 Simplified Block DiagramMemory OrganizationData Memory OrganizationAccessing Data MemorySpecial Function Registers (SFRs), General Purpose Registers (GPRs)Instruction OperandsTwo Operand Instructionsmovwf Instruction formmovwf Instruction Executionmovwf Instruction FormatThe Bank Select Register again....What the heck is the Access Bank?Rules for the ‘access’ bit in instructionsMachine Code Examples for movwfChanging the Bank Select Registermovlb InstructionMove Register (movf)Copying Data Between Banksmovff InstructionThe addwf instructionaddwf Examplesaddwf instruction encodingsubwf Instructionsubwf ExamplesMove literal to w (movlw)Increment (incf)Decrement (decf)How is the instruction register loaded?Goto location (goto)A Simple ProgramWhere are variables stored?C to PIC18 AssemblyPIC18 Assembly to PIC18 Machine Codemptest.asmmptst.asm (cont.)mptst.asm (cont.)mptst.asm (cont.)mptst.asm (cont.)General MPLAB® IDE CommentsClock Cycles vs. Instruction CyclesReview: UnitsPIC18Fxx2PIC16F87x vs PIC18Fxx2What do you need to know?V 0.9 1Microcontroller (µC) vs. Microprocessor (µP)• µC intended as a single chip solution, µP requires external support chips (memory, interface)• µC has on-chip non-volatile memory for program storage, µP does not.• µC has more interface functions on-chip (serial interfaces, Analog-to-Digital conversion, timers, etc.) than µP• µC does not have virtual memory support (I.e, could not run Linux), while µP does.• General purpose µPs are typically higher performance (clock speed, data width, instruction set, cache) than µCs• Division between µPs and µCs becoming increasingly blurredV 0.9 2PIC18Fxx2 µCDC to 40 MhzClock speedAccumulator, 70 instructions ArchitectureAsync serial IO, I2C, SPI, A/D, three 16-bit timers, one 8-bit timerOn-chip modules18F242 has 768 bytes, architecture supports up 4K bytesOn-chip Random Access Memory (RAM) 18F242 has 16K bytes, architecture supports 2Mbytes)On-chip program memory (non-volatile, electrically erasable)16 bitsInstruction widthCommentsFeaturesV 0.9 3PIC18Fxx2 Simplified Block DiagramMultiplier not shownProgram Counter21addressProgram Memory,non-volatile, up to 2M bytes (1M x 16)DOUTRAM File RegistersDataaddress16Inst. Reg12ALUW88bitops888Two operand instructions have the Working Register (w reg) as one operand, and memory or data in the current instruction as the second operand. The destination can be either be wreg or file registers.The instruction register contains the machine code of the instruction currently being executed.8V 0.9 4Memory OrganizationMemory on the PIC18Fxx2 µC is split into two types: Program Memory and Data Memory .PIC18 instructions are stored in program memory, which is non-volatile (contents are retained when power is lost). A PIC18 instruction is 16-bits wide ( 2 bytes). PIC18F242 program memory is 8K x 16 (16 Kbytes); the PIC18 architecture can support up to 1M x 16 (2M bytes) of program memory.PIC18 data is stored in data memory, also known as the file registers, and is a maximum size of 4K x 8. Data memory is volatile (contents are lost when power is lost).V 0.9 5Data Memory OrganizationData Memory is split into banks of 256 locations (0x100 locations)Data Memory MapGPR – General Purpose Registers SFR - Special Function Registers Access Ram (GPR)GPR0x0000x07F0x0800x0FF0x000x7F0x800xFFGPR0x00 0x1000x1FF0xFFGPR0x00 0x200(SFR)Access Ram Low(GPR)Access Ram High0x000x7F0x800xFFBank 0Access RamBank 1Bank 20xFF 0x2FFGPR 0xFFF0xF00SFR0xF7F0xF8018F242 has banks 0, 1, 2 and SFRs (0xF80 –0xFFF). Other versions implement more banks.0x00Bank 150xFFV 0.9 6Accessing Data MemoryThe machine code for a PIC18 µC instruction has only 8 bits for a data memory address which needs 12 bits. The Bank Select Register (BSR) supplies the other 4 bits. Access Ram (GPR)GPR0x000x7F0x800xFFGPR0x000xFFGPR0x00Bank 2PIC18 instructionBank 08-bit addressOPlower 4 bits12-bit addressBank 1Bank Select Register0xFF0x00GPR SFRBank 150xFFV 0.9 7Special Function Registers (SFRs), General Purpose Registers (GPRs)The Bank Select Register and the W register (working register) are examples of Special Function Registers (SFR). There are many SFRs in the PIC18 µC – they are used as control registers and data register for processor subsystems (like the serial interface, or the analog-to-digital converter). We will cover their use and names as we need to.SFRs live in the address range 0xF80 to 0xFFF in data memory.See section 4.9.2 of the datasheet for a complete list of SFRs.General Purpose Registers (GPRs) are locations in data memory that can be used for storage of temporary data; they are not used by the processor subsystems.V 0.9 8Instruction OperandsAn operand is the data that an instruction operates on. Instructions in the PIC18 µC have either zero operands (require no data), one operand, or two operandsThe ‘out 5’ instruction in the Student ID CPU is an example of a one operand instruction.Examples of two operand instructions are addition, subtraction.Examples of one operand instructions are increment, decrement. Examples of no operand instructions SLEEP (halt processor, goto low power mode), CLRWDT (clear watchdog timer).V 0.9 9Two Operand Instructionsdestination operand1operand2operationOne form of a two operand instruction is below. Note that one of the source operands is overwritten! Used by most arithmetic/logical operationssrc1 | src2 ← src1 op src2eg. A ← A + Beg. B ← A - BAnother form, used by the ‘move’ instructions:dest ← src destination sourceV 0.9 10movwf Instruction form“Write contents of W register to data memory location floc”. General form:movwf floc[,a] floc ← (w)floc is a memory location in the file registers (data memory)w is the working registera is data memory access bit, ‘ACCESS’(0) use Access Bank --ignore Bank Select Register (BSR), ‘BANKED’(1), use BSR. (will talk more about this later), [a] means optional usage.When floc is destination, means “modify memory location floc”.movwf 0x70 0x70 ← (w)V 0.9 11movwf Instruction ExecutionAssume the following Memory/Register contents before execution: 0xf90x000x8f0x340x0720x0710x0700x06fLocation ContentsW = 0x2A0xf90x000x2A0x340x0720x0710x0700x06fwrittenW = 0x2A (unaffected)modifiedBEFORE AFTERmovwf


View Full Document

MSU ECE 3724 - Microcontroller (µC) vs. Microprocessor (µP)

Documents in this Course
Timers

Timers

38 pages

TEST 4

TEST 4

9 pages

Flags

Flags

6 pages

Timers

Timers

6 pages

Timers

Timers

54 pages

TEST2

TEST2

8 pages

Load more
Download Microcontroller (µC) vs. Microprocessor (µP)
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Microcontroller (µC) vs. Microprocessor (µP) and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Microcontroller (µC) vs. Microprocessor (µP) 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?