PIC16 MCU Peripherals-Computer Archtecture-Lecture Slides, Slides of Computer Architecture and Organization

Dr. Aabheer Desai delivered this lecture at Bengal Engineering and Science University for Computer Architecture course. It includes: PIC, Microcontroller, Peripherals, Input, Output, ADC, Comparator, Parallel, Port, Timers, Interrupts

Typology: Slides

2011/2012

Uploaded on 07/19/2012

pankitta
pankitta 🇮🇳

5

(4)

18 documents

1 / 20

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
PIC16 MCU Peripherals
Digital I/O
Timers
A/D converter
Comparator
Parallel slave port
Interrupts
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download PIC16 MCU Peripherals-Computer Archtecture-Lecture Slides and more Slides Computer Architecture and Organization in PDF only on Docsity!

PIC16 MCU Peripherals

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

PIC 16F877 Timers/Counters

  • Three hardware timers built in:
    • Timer0 (originally called RTCC, the real-time

counter clock)

  • Timer1– Timer

Programming Timers

  • Clock Sources
    • Internal Clock Makes it a Timer– External Clock Makes it a Counter
      • Basic Registers
        • TMRxL – Timer/Counter Register Low– TMRxH – Timer/Counter Register High– TCON – Timer Control Register– INTCON – Interrupt Control Register

CCS timer functions

  • The number of bits in the timer (8 or 16)

determines the maximum count (256 or65536, respectively).

  • When the timer register overflows and

returns to zero, an overflow flag bit is set.

  • This flag can be polled (tested) to check if

an overflow has occurred or an interruptgenerated, to trigger the required action.

•^

To modify the count period, the timerregister can be preloaded with a givennumber.

  • For example, if an 8-bit register is

preloaded with the value 156, a time-outoccurs after 256 – 156 = 100 clocks.

  • Many timer modules allow automatic

preloading each time it is restarted,

  • For example, the 8-bit timer driven at 1

MHz with a prescale value of 4 counts upto 256 x 4 =

μ

s, at 4

μ

s per bit.

  • A postscaler has a similar effect,

connected at the output of the counter.

Counter Operation

  • A counter/timer register consists of a set of

bistable stages (flip-flops) connected incascade (8, 16, or 32 bits).

  • When used as a counter, a pulse train fed

to its least significant bit (LSB) causes theoutput of that stage to toggle at half theinput frequency.

Timer Operation in 16F

  • The count can be recorded at any chosen

point in time; alternatively,

  • an interrupt can be generated on overflow

to notify the processor that the maximumcount has been exceeded.

  • If the register is preloaded with a suitable

value, the interrupt occurs after a knowncount.

  • The counters are more frequently used as

timers, with the input derived from theMCU clock oscillator.

  • Since the clock period is accurately

known, the count represents an accuratetimed period.

  • It can therefore be used to measure the

period or frequency of an input signal orinternal intervals or generate a regularinterrupt.

General Timer Operation

Binary Counter

Pre-scaler(clockdivide)

Post-scaler(outputdivide)

TimerOverflow/Timeout(Interrupt)Flag

ClockSourceSelect

InstructionClockExternal Pulse

Captureregister Compareregister

Capturesignal

Match flag

A binary counter is used as a timer when driven from the clock

Timer 0

  • Timer0 is an 8-bit

register that can countpulses at RA4; for thispurpose, the input iscalled T0CKI (Timer0clock input).

  • Timer0 has a

prescaler that dividesby up to 128;

Timer 2

  • Timer2 has a prescaler and postscaler that

divide by up to 16.

Assignment

  • Generate a Pulse of 1 Hz at one output

and show it on an LED

  • Count the number of times key is pressed

by your friend.