You are on page 1of 6

Embedded Systems Design: A Unified

Hardware/Software Introduction

Chapter 4 Standard Single Purpose


Processors: Peripherals

1
Introduction

• Single-purpose processors
– Performs specific computation task
– Custom single-purpose processors
• Designed by us for a unique task
– Standard single-purpose processors
• “Off-the-shelf” -- pre-designed for a common task
• a.k.a., peripherals
• serial transmission
• analog/digital conversions

Embedded Systems Design: A Unified 2


Hardware/Software Introduction, (c) 2000 Vahid/Givargis
Timers, counters, watchdog timers

• Timer: measures time intervals


– To generate timed output events
• e.g., hold traffic light green for 10 s
– To measure input events Basic timer

• e.g., measure a car’s speed Clk


16-bit up 16 Cnt
counter
• Based on counting clock pulses Top
• E.g., let Clk period be 10 ns Reset
• And we count 20,000 Clk pulses
• Then 200 microseconds have passed
• 16-bit counter would count up to 65,535*10 ns =
655.35 microsec., resolution = 10 ns
• Top: indicates top count reached, wrap-around

Embedded Systems Design: A Unified 3


Hardware/Software Introduction, (c) 2000 Vahid/Givargis
Counters

• Counter: like a timer, but counts Timer/counter


pulses on a general input signal Clk
2x1 16-bit up 16 Cnt
rather than clock mux counter

– e.g., count cars passing over a sensor Cnt_in Top

– Can often configure device as either a Reset


Mode
timer or counter

Embedded Systems Design: A Unified 4


Hardware/Software Introduction, (c) 2000 Vahid/Givargis
Other timer structures
• Interval timer 16/32-bit timer

– Indicates when desired time Clk 16-bit up


counter 16 Cnt1
Timer with a terminal
interval has passed count
– We set terminal count to 16-bit up
Top1
Clk
desired interval counter 16 Cnt
16-bit up
• Number of clock cycles counter 16 Cnt2

= Desired time interval / Reset Top2


Clock period
=
• Cascaded counters Top Time with prescaler

• Prescaler Clk Prescaler 16-bit up


counter
Terminal count
– Divides clock
– Increases range, decreases
resolution Mode

Embedded Systems Design: A Unified 5


Hardware/Software Introduction, (c) 2000 Vahid/Givargis
Example: Reaction Timer
indicator reaction
/* main.c */
light button
#define MS_INIT 63535
LCD time: 100 ms void main(void){
int count_milliseconds = 0;

• Measure time between turning light on


configure timer mode
set Cnt to MS_INIT

and user pushing button wait a random amount of time


turn on indicator light
– 16-bit timer, clk period is 83.33 ns, counter start timer

increments every 6 cycles while (user has not pushed reaction button){
if(Top) {
– Resolution = 6*83.33=0.5 microsec. stop timer
set Cnt to MS_INIT
– Range = 65535*0.5 microseconds = 32.77 start timer
reset Top
milliseconds }
count_milliseconds++;

– Want program to count millisec., so }


turn light off
initialize counter to 65535 – 1000/0.5 = }
printf(“time: %i ms“, count_milliseconds);

63535
Embedded Systems Design: A Unified 6
Hardware/Software Introduction, (c) 2000 Vahid/Givargis

You might also like