PIC 18 F Architecture PIC 18 F Architecture

  • Slides: 24
Download presentation
PIC 18 F Architecture

PIC 18 F Architecture

PIC 18 F Architecture

PIC 18 F Architecture

PIC 18 F �Harvard Architecture ◦ Program Memory: Flash 4 KB to 128 KB

PIC 18 F �Harvard Architecture ◦ Program Memory: Flash 4 KB to 128 KB ◦ Data Memory: SRAM 256 to 3968 bytes ◦ Data EEPROM: 128 bytes to 1 KB if any � 18 to 100 Pins �I/O Pins: 16 to 70 � 25 MHz to 48 MHz

MCU-Microcontroller Unit Block Diagram

MCU-Microcontroller Unit Block Diagram

MPU-Microprocessor Unit & Memory Block Diagram

MPU-Microprocessor Unit & Memory Block Diagram

PIC 18 F Architecture

PIC 18 F Architecture

Program & Data Memories

Program & Data Memories

Data Memory showing Access Bank & Address Range

Data Memory showing Access Bank & Address Range

I/O Ports �Five I/O ports �PORT A through PORT E �Most I/O pins are

I/O Ports �Five I/O ports �PORT A through PORT E �Most I/O pins are multiplexed �Generally have eight I/O pins with a few exceptions �Addresses already assigned to these ports in the design stage �Each port is identified by its assigned SFR

I/O Ports

I/O Ports

Processes of Data Transfer

Processes of Data Transfer

MCU Support Devices �Timers ◦ CCP Modules: Capture, Compare and PWM �Serial Communications ◦

MCU Support Devices �Timers ◦ CCP Modules: Capture, Compare and PWM �Serial Communications ◦ MSSP: Master Synchronous Serial Port ◦ Addressable USART �A/D converter �PSP: Parallel Slave Port �Data EEPROM

MCU Support Devices

MCU Support Devices

PIC 18 F Special Features �Sleep Mode �WDT: Watchdog Timer �Code Protection �In-Circuit Serial

PIC 18 F Special Features �Sleep Mode �WDT: Watchdog Timer �Code Protection �In-Circuit Serial Programming �In-Circuit Debugger

PIC 18 F Architecture

PIC 18 F Architecture

PIC 18 F Instructions and Assembly Language �Has 77 instructions ◦ Earlier PIC family

PIC 18 F Instructions and Assembly Language �Has 77 instructions ◦ Earlier PIC family of microcontrollers have either 33 or 35 instructions. Upward Compatible. �In PIC 18 F instruction set, all instructions are 16 -bit word length except four instructions that are 32 -bit length

Instruction Description � Copy (Move) 8 -bit number (Literal) into W register ◦ Mnemonics:

Instruction Description � Copy (Move) 8 -bit number (Literal) into W register ◦ Mnemonics: MOVLW 8 -bit ◦ Binary format: 0000 1110 XXXX (any 8 -bit number) � Copy (Move) contents of W register into PORTC (File) ◦ Mnemonics: MOVWF PORTC, a �(‘a’ indicates that PORTC is in the Access Bank) ◦ Binary format: 0110 1000 0010 (82 H is PORTC address)

Illustrative Program: Displaying a Byte at an I/O Port �Problem statement: ◦ Write instructions

Illustrative Program: Displaying a Byte at an I/O Port �Problem statement: ◦ Write instructions to light up alternate LEDs at PORTC �Hardware: ◦ PORTC �bidirectional (input or output) port; should be setup as output port for display ◦ Logic 1 will turn on an LED

Interfacing LEDs to PORTC

Interfacing LEDs to PORTC

Program �Logic 0 to TRISC sets up PORTC as an output port �Byte 55

Program �Logic 0 to TRISC sets up PORTC as an output port �Byte 55 H turns on alternate LEDs �MOVLW �MOVWF �MOVLW LEDS �MOVWF �SLEEP 00 ; Load W register with 0 TRISC, 0 ; Set up PORTC as output 0 x 55 ; Byte 55 H to turn on PORTC, 0 ; Turn on LEDs ; Power down

Assembled Program Address Hex Mnemonics Comments 000000 0 E 00 MOVLW 00 ; Load

Assembled Program Address Hex Mnemonics Comments 000000 0 E 00 MOVLW 00 ; Load W with 0 s 000002 6 E 94 MOVWF TRISC, 0 ; Set PORTC as output 000004 0 E 55 MOVLW 0 x 55 ; Load 55 to turn on LEDs 000006 6 E 82 MOVWF PORTC, 0 ; Turn on LEDs 000008 0003 SLEEP ; Power Down

Execution of the instruction MOVWF PORTC

Execution of the instruction MOVWF PORTC

MPLAB IDE Simulator

MPLAB IDE Simulator

Embedded System Microcontroller-based Time and Temperature System

Embedded System Microcontroller-based Time and Temperature System