Embedded Systems: Guide to Timers, Counters, and Serial Transmission, Slides of Computer Science

Explore the integration of peripherals such as timers, counters, and serial transmission using uarts in embedded systems. Learn about timer structures, counter functions, and serial transmission techniques. Discover the role of parity, baud rate, and synchronization in uart communication.

Typology: Slides

2012/2013

Uploaded on 03/22/2013

dhritiman
dhritiman 🇮🇳

4.7

(6)

106 documents

1 / 17

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
4-Integrating Peripherals in
Embedded Systems
1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Embedded Systems: Guide to Timers, Counters, and Serial Transmission and more Slides Computer Science in PDF only on Docsity!

4-Integrating Peripherals in

Embedded Systems

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

Counters

• Counter: like a timer, but

counts pulses on a general

input signal rather than

clock

  • e.g., count cars passing over a sensor
  • Can often configure device as either a timer

or counter

16-bit up counter

Clk 16

Cnt_in

2x mux

Mode

Timer/counter

Top

Reset

Cnt

Other timer structures

  • Interval timer
    • Indicates when desired time interval

has passed

  • We set terminal count to desired

interval

  • Number of clock cycles = Desired time interval / Clock period
  • Cascaded counters
  • Prescaler
  • Divides clock
  • Increases range, decreases

resolution

Top

Time with prescaler

16-bit up counter

Clk Prescaler

Mode

16-bit up counter

Clk 16

Terminal count

Top

Reset

Timer with a terminal count

Cnt

16-bit up counter

Clk

16-bit up counter

Cnt

Top

16/32-bit timer

Cnt

Watchdog timer

  • Must reset timer every X

time unit, else timer

generates a signal

  • Common use: detect failure,

self-reset

  • Another use: timeouts
    • e.g., ATM machine
    • Scalereg: 11-bit timer, 1 μsec resolution.
    • Scalereg Top signal toggles every 2^11 *1μsec= 2. msec
    • Hence, Timereg: 16-bit timer, 2 msec. resolution
    • timereg value = maxCnt-time needed/resoloution
    • X = 65535-2min/2msec
    • X=65535-2*60/0.002 X=

scalereg

checkreg

timereg to system reset or interrupt

osc clk prescaler

Top overflow

12 MHz 1MHz^ 11 bit Up X counter

16 bit Up counter 0 disable 1 enable

/* main.c */

main(){ wait until card inserted call watchdog_reset_routine

while(transaction in progress){ if(button pressed){ perform corresponding action call watchdog_reset_routine }

/* if watchdog_reset_routine not called every < 2 minutes, interrupt_service_routine is called */ }

watchdog_reset_routine(){ /* checkreg is set so we can load value into timereg. Zero is loaded into scalereg and 11070 is loaded into timereg */

checkreg = 1 scalereg = 0 timereg = 5535 }

void interrupt_service_routine(){ eject card reset screen }

Serial Transmission Using UARTs

  • UART: Universal Asynchronous

Receiver Transmitter

  • Takes parallel data and transmits serially
  • Receives serial data and converts to parallel
  • Parity: extra bit for simple error

checking

  • Start bit, stop bit
  • Baud rate
    • signal changes per second
    • bit rate usually higher

embedded 1 device 0 0 1

Sending UART

Receiving UART

start bit data

end bit

1 0 0 1 1 0 1 1

Serial Transmission Using UARTs

  • Clocks on sender and receiver are

never exactly in sync

  • Requires synchronization of receiver
  • High-low transition signals frame boundary

UART Tx Signals

• Example for two transmissions

Example UART /MAX 232 interface

MAX

• The MAX232 is a dual

driver/receiver that includes

a capacitive voltage

generator to supply

standard voltage levels for

TIA/EIA-232-F interface.

• Uses a single 5-V supply.

• Each receiver converts

TIA/EIA-232-F inputs to 5-V

TTL/CMOS levels.

• These receivers have a 14

MAX232: Receiver

MAX232: Driver