Presentation is loading. Please wait.

Presentation is loading. Please wait.

Department of Electronic & Electrical Engineering Lecture 2 ● Introduction to IO ● Using a subroutine ● Driving a 7seg display.

Similar presentations


Presentation on theme: "Department of Electronic & Electrical Engineering Lecture 2 ● Introduction to IO ● Using a subroutine ● Driving a 7seg display."— Presentation transcript:

1 Department of Electronic & Electrical Engineering Lecture 2 ● Introduction to IO ● Using a subroutine ● Driving a 7seg display

2 Department of Electronic & Electrical Engineering Background reading Quintessential PIC. Chapter 11 (lots of detail here that we skip in the lecture). ➢ IO ports. ➢ Using a lookup table. ➢ call and retlw instructions ➢ Seven segment LED display.

3 Department of Electronic & Electrical Engineering Input and output (from PIC16F84A sheet) 4.1 PORTA and TRISA Registers PORTA is a 5-bit wide, bi-directional port. The corresponding data direction register is TRISA. Setting a TRISA bit (= 1) will make the corresponding PORTA pin an input (i.e., put the corresponding output driver in a Hi-Impedance mode). Clearing a TRISA bit (= 0) will make the corresponding PORTA pin an output (i.e., put the contents of the output latch on the selected pin)

4 Department of Electronic & Electrical Engineering PORTA and TRISA

5

6 Department of Electronic & Electrical Engineering Selecting a data bank The status register has various bits that can be read and written. See next slide.....

7

8 Department of Electronic & Electrical Engineering Configuring PORTA

9 Department of Electronic & Electrical Engineering Example: copying data from portA to portB bsf STATUS,5 ;select bank 1 movlw B'00000000' ;set up port B as all outputs movwf TRISB movlw B'00001111' ;set up port A 0-3 as inputs movwf TRISA bcf STATUS,5 ;select bank 0 loop movfw PORTA ; input PORTA movwf PORTB ; output to PORTB goto loop ; loop forever end

10 Department of Electronic & Electrical Engineering Seven Segment LED Display

11 Department of Electronic & Electrical Engineering Seven Segment Display Internal Circuit

12 Department of Electronic & Electrical Engineering Connecting to PORTA using wires.

13 Department of Electronic & Electrical Engineering Converting to seven segment display ● We have 4 bits of input (a hex number). ● We want to display the corresponding character on the 7seg display. ● Each segment can be represented by a bit of a binary number. ● The problem is to lookup the correct 7seg code for each 4bit number. ● This can be done using a lookup table.

14 Department of Electronic & Electrical Engineering Lookup table using programmed return. ; stuff here..... ; w contains the 4 bit number call conversion ; w now contains the 7 segment code ;....more stuff here ; convert 4bit number in w into a seven segment code. conversion: ; this is just a label for the assembler addwf PCL ; add w to the PC (jump) retlw B'10111110' ; 0 return 7 seg code. retlw B'00001100' ; 1 retlw B'11011010' ; 2 retlw B'11110010' ; 3 retlw B'11100100' ; 4

15 Department of Electronic & Electrical Engineering Demo Do a demo now Dr Leonard....

16 Department of Electronic & Electrical Engineering


Download ppt "Department of Electronic & Electrical Engineering Lecture 2 ● Introduction to IO ● Using a subroutine ● Driving a 7seg display."

Similar presentations


Ads by Google