PIC Microcontroller I/O Ports and Digital I/O Operations, Slides of Computer Architecture and Organization

An overview of the digital i/o peripherals in pic16 mcus, including i/o ports, i/o pin operation, and reading data. It covers the use of trisx registers to control the direction of i/o ports, the difference between analog and digital i/o pins, and the importance of setting the correct direction before using the ports. It also explains how to read data from a port and provides examples of low-level programming using trisx and portx.

Typology: Slides

2011/2012

Uploaded on 07/19/2012

pankitta
pankitta 🇮🇳

5

(4)

18 documents

1 / 22

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
PIC Peripherals
Digital I/O
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download PIC Microcontroller I/O Ports and Digital I/O Operations and more Slides Computer Architecture and Organization in PDF only on Docsity!

PIC Peripherals^ Digital I/O

PIC16 MCU Peripherals • Digital I/O• Timers• A/D converter• Comparator• Parallel slave port• Interrupts

I/O pin operation CPU Data Bus^

DataDirectionTri-stateLatch^ OutputEnableOutput OutputCurrentDataDriverLatch InputDataLatch Write TRIS bit Write data bitRead databit Analogue inputmultiplexer The pin can be set for input or output data transfer

16F877 I/O Ports • The 16F877 has the following digital I/Oports available:• Port A RA0–RA^

6 bits

  • Port B^ RB0–RB

8 bits

  • Port C^ RC0–RC

8 bits

  • Port D^ RD0–RD

8 bits

  • Port E^ RE0–RE

3 bits

  • Total digital I/O available

33 pins

TRISx (Low Level Prog.) • Used to Control Direction of PORTx – Input or Output– No Bidirectional Use Without Changing TRISXBack and Forth • Must Set TRISx^

Before^ Using PORTx

  • TRISx = 0^ 

PORTx Is OUTPUT (0 = O)

  • TRISx = 1^ 

PORTx Is INPUT (1 = I)

Example MOVLW 0x0^ ;WREG = 0MOVWF TRISB^ ;make PORTB output

L1^ MOVLW^

0x55^ ;WREG = 55HMOVWF PORTB^ ;put 55H

on PORTB CALL^ DELAYMOVLW^ 0xAA

;WREG = AAH MOVWF^ PORTB

;put AAH^

on PORTB CALL^ DELAYGOTO^ L^

;^ Loop

PORTA

  • Only 7 Pins (RA0-RA6)• RA6 is Dual-Use^ – Not Available If Using a Crystal Oscillator forFrequency Provision • NOTE: You Still Write All 8 Bits to TRISAand PORTA^ – Excess Data Goes in the Bit Bucket, So BeCareful!

PORTB

  • All 8 Pins (RB0-RB7)• Set By TRISB• PORTA and PORTB Have a Dual Role^ – Multiplexes an A/D Converter (Later) • DO NOT USE PORT A and PORTB WhenYou Need the A/D Converter

PORTD

  • 8 Pins• Uses TRISD• BUT, PORTD Has Dual Use^ – Later

PORTE

  • Only 3 Pins!• Uses TRISE to Set Direction• Also Has Alternate Functions

Pipeline for Read Followed by Write I/O

Port Status on Reset • Defaults – TRISx = 0xFF– All Ports Become INPUT Ports

Bit-Oriented Instructions inAssembly • BSF^ Bit^ Set^ fileReg• BCF^ Bit^ Clear

fileReg

  • BTG^ Bit

Toggle fileRe

g

  • BTFSC^ Bit

Test^ fileReg,

Skip if^ Clear

  • BTFSS^ Bit

Test^ fileReg,

Skip if^ Set

  • In CCS C compiler, all this Assembly storyis just part of few C lines!