Top Banner
MICROPROCESSORS A (17.383) Fall 2011 Lecture Outline l Class # 04 September 27, 2011 Dohn Bowden 1
77

MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Jul 19, 2018

Download

Documents

truongkiet
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

MICROPROCESSORS A (17.383)

Fall 2011

Lecture Outline

lClass # 04

September 27, 2011

Dohn Bowden

1

Page 2: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Today’s Lecture

• Syllabus review

• Microcontroller Hardware and/or Interface

• Programming/Software

• Lab

• Homework

• Finish Lab # 2

2

Page 3: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

CCoursed iAdmin

3

Page 4: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Administrative

• Admin for tonight …

– Syllabus Highlights

• Exam # 1 … next week (October 04 2011)• Exam # 1 … next week (October 04, 2011)

• Lab # 1 … is due tonight

• CHANGE … Lab report for Lab # 2 is due October 18, 2011

4

Page 5: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Syllabus ReviewWeek Date Topics Lab Lab Report Due

1 09/06/11 Intro, Course & Lab Overview, Microcontroller Basics 1

2 09/13/11 PIC16F684 Overview and General Input/Output 1 con’t

3 09/20/11 Switches 2

4 09/27/11 Seven Segment LEDs 2 con’t 1

5 10/04/11 Examination 1

6 10/11/11 Analog to Digital Conversion 3

7 10/18/11 A l t Di it l C i ’t 3 ’t 27 10/18/11 Analog to Digital Conversion con’t 3 con’t 2

8 10/25/11 Lab 3, 4

9 11/01/11 LCD Interface and Assembly Language 4 con’t 3

10 11/08/11 Comparators Timers Pulse Width Modulation (PWM) 510 11/08/11 Comparators, Timers, Pulse Width Modulation (PWM) 5

11 11/15/11 Mixed C & Assembly Programming/Course Project Project 4

12 11/24/11 Examination 2

13 11/29/11 Course Project Project 5/ / j j

14 12/06/11 Final Exam/Course Project Brief and Demonstration Demo

5

Page 6: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Microcontroller HardwareMicrocontroller Hardware and / orand / or

Interfaces

6

Page 7: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

PIC16F684 Interfacing

• Voltage Regulator Circuit

• Seven-Segment LEDs

7

Page 8: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Transition From the PICkit 1 Development Board

• Thus far we have been using the PICkit board

– All required circuitry was on the board

– However … the board was limited by it’s design and components

• We want to be able to design our own circuitsg

– Would be cost prohibited to use the PICkit as our backbone

8

Page 9: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Voltage Regulator Circuit

• First consideration … power requirements

– Need to power the PIC16F684 and its external interface components

9

Page 10: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Voltage Regulator Circuit

10

Page 11: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

LM7805 Pin Connections - Top View

LM7805 Pin Connections Top ViewLM7805 Pin Connections - Top View

11

Page 12: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Breadboard

• Locate your circuit near the breadboard terminals

– Will be using this circuit for all our projects

– Therefore … use minimal space on the board

• Keep the wiring as short as possibleg

– Less EMI issues

• Test your circuit before you install sensitive components

12

Page 13: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Testing Your Voltage Regulator

• Voltage checks

• Oscilloscope

13

Page 14: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Power Indicator Circuit

• PIC16F684 MUST NOT be removed or installed while energized

• Therefore … add an LED for a visual indication that power is present

470 ohms470 ohms

14

Page 15: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

External Interface Components

• External interface components …

– A breadboard will allow for additional components not available on the PICkit 1

– Additional Switches– Additional LEDs– Seven-Segment LEDs– LCD Displays– Etc.Etc.

15

Page 16: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

The Seven-Segment LED …The Seven Segment LED …

16

Page 17: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

The Seven-Segment LED

17

Page 18: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

The Seven-Segment LED

• LEDs in seven-segment display are not isolated from each other • Either all of the cathodes or anodes are connected together• Either all of the cathodes, or anodes, are connected together• The other end of each LED is individually available• Means fewer electrical connections

– allows us to easily enable or disable a particular digit by controlling the common lead

18

Page 19: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

The Seven-Segment LED – Our Labs

• We will be using the common anode configuration

19

Page 20: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

The Seven-Segment LED

20

Page 21: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Lighting Each Digit

• To light each digit separately, we would need 14 I/O lines on the microcontroller

• This does not include any other I/O lines needed for items such as switches

• Therefore, due to the above hardware limitations

– We will only light one digit at a time, with a process called strobing

– Strobing 7-segment displays basically involves displaying a number on one display for a short while, and then turning off that display while you display another number on another display

21

display

Page 22: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Lighting Each Digit

• The displays are in fact flashing on and off at a high rate of speed, giving the impression that they are constantly ongiving the impression that they are constantly on

• To avoid flickering …

– Each digit must be on at least 50 times per second

• We will use an electronic switch to select the digit …

– A transistorA transistor

22

Page 23: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Transistors

• The easiest way to understand transistors is to think of them as switchesswitches

• You can switch a big current …

– between the collector and emitter

• With a much smaller current (in the base)

23

Page 24: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Transistors

NPN transistor

One mnemonic device forPNP transistor

One mnemonic device for identifying the symbol for the NPN transistor is "not pointing in."

One mnemonic device for identifying the symbol for the PNP transistor is "pointing in."

24

p g

Page 25: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

NPN transistor as a switch (on)

25

Page 26: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

NPN transistor as a switch (off)

26

Page 27: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

PNP Transistors

• While an NPN transistor conducts when a current flows into the basebase

• A PNP transistor will conduct when …

– No current flows into the base

• And stop conducting when …

– A current flows into the base.A current flows into the base.

27

Page 28: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

PNP transistor as a switch (on)

28

Page 29: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

PNP transistor as a switch (off)

29

Page 30: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

PNP Transistor – Our Labs

• We will be using the PNP Transistor …

• Therefore … the transistors we will use will conduct when …

– No current flows into the base

• And stop conducting when … g

– A current flows into the base

30

Page 31: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Microcontroller and 7-Segment LED Circuit

0 = Selected 0 = On

31

0 = Selected1 = Not Selected

0 On1 = OFF

Page 32: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

32

Page 33: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Programming / Software

33

Page 34: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Programming

• Commands/instructions that we will encounter tonight

• C commands

• PIC16F684 control

34

Page 35: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

“C” commands – Learned to Date …C commands Learned to Date …

35

Page 36: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

C commands – Learned to Date

• C program structure

• Comments

• # include

• Integer variables

f• for

• while

• NOP()

functions

36

• functions

Page 37: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

C commands – Learned to Date (con’t)

• if conditional

• else

• else if

• switch

• Constant Declaration

37

Page 38: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

C commands – Learned to Date (con’t)

• Bitwise Operators

a == b Tests for equality

a != b Test for inequalityq y

a > b Greater than

a < b Less than

a >= b Greater than or equal toa > b Greater than or equal to

a <= b Less than or equal to

38

Page 39: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

New “C” commands …New C commands …

39

Page 40: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

NEW C Commands

• Bitwise Operators

– << Shift Left– >> Shift Right

• arrays or look-up tables

40

Page 41: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Bitwise Operators …Bitwise Operators …

41

Page 42: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Shifting Bits

• Another type of useful bitwise operation is the shift

• We can shift bits either to the left (<<) or to the right (>>)

• Why use a shift? …

– To perform an operation on a certain bit

• The bit of interest can be moved to a position where the operation can be performedoperation can be performed

42

Page 43: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Binary Operators

• << Shift Left

• Drops the number of bits specified on the left• Replaced with zeros

• >> Shift Right

• Drops the number specified on the right• Replaced with zeros

43

Page 44: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

<< Shift Left

• Shift Left by 2

1 1 1 0 1 1 0 0

<< by 2

==============================

1 0 1 1 0 0 0 0

• We shifted the bit pattern to the left by 2 positions and• We shifted the bit pattern to the left by 2 positions … and …

– Replaced bits 0 and 1 positions with two zeros

– The original bits 6 and 7 have been replaced by bits 4 and 5

44

Page 45: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

>> Shift Right

• Shift Right by 1

1 1 1 0 1 1 0 0

>> by 1

==============================

0 1 1 1 0 1 1 0

• We shifted the bit pattern to the Right by 1 position and• We shifted the bit pattern to the Right by 1 position … and …

– Replaced in the bit 7 position with a zero

– The original bit 0 has been replaced with bit 1

45

Page 46: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Applying the Shift Operator to the Microcontroller

PICKit1_LEDs = 0b010000; // PORTA value to light D0

• We have the above variable in our program code

• We need to set RA4 equal to the value of the bit in position 4 (the 5th bi f h i h ll i h bi 0)5th bit from the right … recall we start with bit 0)

• What is one way of doing that?

46

Page 47: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Applying the Shift Operator to the Microcontroller

PICKit1_LEDs = 0b010000; // PORTA value to light D0RA4 = (PICKit1_LEDs & 0b010000) >> 4;

0 1 0 0 0 0

AND (&)

0 1 0 0 0 0

============

0 1 0 0 0 0

• Shift Right by 4

0 1 0 0 0 0

>> by 4

============

0 0 0 0 0 1

47• Resulting in RA4 equaling 1

<Unknown User>
Pencil
<Unknown User>
Pencil
<Unknown User>
Pencil
Page 48: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Arrays or Look-up Tables …Arrays or Look up Tables …

48

Page 49: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Arrays or Look-up Tables

• There are times when you want a variable to hold multiple values

• For example … you may want the variable scores to hold 100 student test scores

• An array or look-up table is a data structure that can store multiple values of the same type

49

Page 50: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Declaring an Array

• The array format is as follows:

type array_name[size];

• To declare an array … you must specify:

– The array Type … (int, char, float, etc)– Array name– Array size

• To specify the array size you place the number of values• To specify the array size … you place the number of values that the array can store within brackets that follow the array name

50

Page 51: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Declaring an Array

int scores[100];

• Example …

int scores[100];

Th fi t l t i l t d t iti 0•The first array element is located at position zero … 0

•The last array element is located at [array size – 1]

•Therefore … the first is at …

scores[0];scores[0];

•The last element is at …

51

score[99];

Page 52: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Initializing Arrays

• The following statement initializes the integer array scores to the values 80, 70, 90, 85, and 80values 80, 70, 90, 85, and 80

int scores[5] = {80, 70, 90, 85, 80};

• You do not need to fill all the space allocated …

int scores[5] = {80, 70, 90};

• Depending on the compiler, it may assign 0 to the elements that p g p , y gyou do not assign explicit values

52

Page 53: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Accessing Array Elements

• Using the previous example …

int scores[5] = {80, 70, 90, 85, 80};

• If we had the following• If we had the following …

i = 2;

scores[i];scores[i];

• Scores would equal …

scores[i] = 90

• Remember with 5 items they will be numbered 0 through 4

53

• Remember … with 5 items … they will be numbered 0 through 4

Page 54: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Alternate Method of Initializing Arrays

• Initializing arrays without specifying the size of the array …

• If you had the following …

int scores[] = {80, 70, 90, 85, 80};

• An array would be created to just fit the values specified … 5j

54

Page 55: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Utilizing Arrays With Microcontrollers

• We could create arrays to hold the PORTA and TRISA values for lighting D0 through D7 LEDs on the PICKit1

const char PORTA_Values[] = {0b010000, // D00b…. // D10b…. // D1……0b000010}; // D7

• Then … set PORTA as follows:

PORTA = PORTA_Values[0]; // Sets PORTA = 0b010000

55

Page 56: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

General Programming …General Programming …

56

Page 57: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Software Thoughts …

• Re-use your code where possible

– Copy code that works from one program to another

– Create yourself a “database”

• When writing Code … do small pieces at a timeg

– Once it’s working … move to the next part

– Integrate each part until the code is complete

57

Page 58: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Exam #1 Review …Exam #1 Review …

58

Page 59: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Review – Exam # 1

• Review all the lecture material

• Basic Microcontroller facts

• Examples of microcontroller applications

• How does the Microcontroller compare to the typical of a personal computer?

• Features and layout of the PIC16F684Features and layout of the PIC16F684

• PICkit™ 1 Flash Starter Kit

59

Page 60: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Review – Exam # 1

• Microchip’s MPLAB integrated development environment (IDE)

• PICC Pro C Compiler

• Typical Tasks for developing an embedded controller application

• Know the PIC16F684 Features

• Understand the Program and Data Memory Configurations

60

Page 61: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Review – Exam # 1

• PIC16F684 Interfacing

– Switches

– LEDs

– Voltage Regulator Circuit g g

– Seven-Segment LEDs

61

Page 62: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Review – Exam # 1 - C commands

• C program structure

• Comments

• # include

• Integer variables

f• for

• while

• NOP()

functions

62

• functions

Page 63: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Review – Exam # 1 - C commands – (con’t)

• if conditional

• else

• else if

• switch

• Constant Declaration

63

Page 64: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Review – Exam # 1 - C commands – (con’t)

• Tests

a == b Tests for equality

a != b Test for inequalityq y

a > b Greater than

a < b Less than

a >= b Greater than or equal toa > b Greater than or equal to

a <= b Less than or equal to

64

Page 65: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Review – Exam # 1 - C commands – (con’t)

• Bitwise Operators

– << Shift Left– >> Shift Right

• arrays or look-up tables

65

Page 66: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Review – Exam # 1 – PIC16F684 Control

• PORTA

• TRISA

• PORTC• PORTC

• TRISC

• R&#

• Configuration Word• Configuration Word

• Numbering Formats

66

Page 67: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Material to Bring to the Exam …

• Electronic versions of all your lab programs … Labs 1 and 2

• PICkit™ 1 Flash Starter Kit … including the PIC16F684 and USB cable

• A calculator …

• Your laptop … if you use it for programming the PIC16F684

67

Page 68: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

ANY

QUESTIONS

RELATED TO

THE EXAM

????

68

Page 69: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

LabLab

69

Page 70: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Peer Review of Software …

70

Page 71: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Peer Review of Software Developed

• How did you write your code?

• What problems did you encountered?

• Any questions that you need resolved?

71

Page 72: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Next Week …

72

Page 73: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Next Class Topics

• Exam #1

73

Page 74: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Home Work

74

Page 75: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Homework

1. Study for Exam #1

2. Bring required Exam Materials to class next week

3 Read as required the C commands discussed in today’s lecture3. Read as required the C commands discussed in today’s lecture found in the text (Programming in C)

d h d l f h4. Read the PIC16F684 data manual sections for the registers encountered tonight

5. Finish Lab #2

6. Lab report for Lab # 2 is due October 18, 2011

75

Page 76: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

Time to

S L bStart Lab …

76

Page 77: MICROPROCESSORS A (17.383) Fall 2011 Lecture Outlinefaculty.uml.edu/dbowden/classpages/2011_fall_kcs/17-383/Ref... · 11 11/15/11 Mixed C & Assembly Programming/Course Project Project

References

1. PIC16F684 Data Sheet 41202F

77