260 likes | 359 Views
Prof. Jorge A. Ramón. Introducción a Microcontroladores. Microcontroller. Microprocessor. VS. CISC Architecture Many pins Many instructions External devices needed for operation (memory, I/O, etc). RISC Architecture Fewer pins Fewer instructions
E N D
Prof. Jorge A. Ramón Introducción a Microcontroladores
Microcontroller Microprocessor VS • CISC Architecture • Many pins • Many instructions • External devices needed for operation (memory, I/O, etc) • RISC Architecture • Fewer pins • Fewer instructions • No external devices needed for operation (memory, I/O, etc are already built into IC)
Microchip PIC16F84 Microcontroller Outline 68 bytes 8 bits 1K x 14 35 instructions 64 bytes 5 bits 8 bits
Clock / Instruction Cycle • Q1 Instruction Fetch • Q2 Instruction Decode • Q3 Execute • Q4 Write Back Pipelining: each instruction is executed in one cycle. Two cycles for JUMP and CALL instructions .
Instruction Set Summary • Byte Oriented • Bit Oriented • Literal • Control Operations Only 35 instructions!! Impressive!!!
Byte Oriented • CLRF • DECF • INCF • ADDWF
Bit Oriented • BCF • BSF
Literal • MOVLW • ADDLW • ANDLW • IORLW • XORLW
Control Operations • CALL • RETURN • GOTO • SLEEP
Programming Example Setting PORTB as Output • Set RP0 in Status Register to switch to BANK1. This allows access to TRISB. • Write 0x00 into TRISB. • Clear RP0 in Status Register to switch to BANK0. This allows access to PORTB.
Programming Example Setting PORTB as Output • BSF STATUS, RP0 • MOVLW 0x00 • MOVWF TRISB • BCF STATUS, RP0 • MOVLW 0xFF • MOVWF PORTB
Assembly Programming Steps to write some code • Tell the assembler which MPU you are using. • Include the header file. • Set PC to 0 • Write some code • Keep an endless loop. • Use the end directive.