33
RMR©2012 Maths is not everything Embedded Systems 4 - Hardware Architecture CPU Input/Output mechanisms Memory Buses and Aux I/O Input/Output interfaces Power Management

S emb t7-arch_bus

Embed Size (px)

Citation preview

Page 1: S emb t7-arch_bus

RMR©2012

Maths is not everything

Embedded Systems4 - Hardware Architecture

CPUInput/Output mechanisms

Memory Buses and Aux I/O

Input/Output interfacesPower Management

Page 2: S emb t7-arch_bus

RMR©2012

Maths is not everything

CPU Buses

Page 3: S emb t7-arch_bus

RMR©2012

Maths is not everything

© 2

008

Way

ne W

olf

CPU bus

Connects CPU to:memory;

devices.

Protocol controls communication between entities.

3

Page 4: S emb t7-arch_bus

RMR©2012

Maths is not everything

© 2

008

Way

ne W

olf

Bus protocol

Determines who gets to use the bus at any particular time.Governs length, style of communication.

4

Page 5: S emb t7-arch_bus

RMR©2012

Maths is not everything

© 2

008

Way

ne W

olf

Four-cycle handshake

Basis of many bus protocols.Uses two wires:

enq (enquiry);

ack (acknowledgment).

dev1 dev2

enq

ack

data

Page 6: S emb t7-arch_bus

RMR©2012

Maths is not everything

© 2

008

Way

ne W

olf

Four-cycle example

time

enq

ack

data

1

2

3

4

Page 7: S emb t7-arch_bus

RMR©2012

Maths is not everything

© 2

008

Way

ne W

olf

Typical bus signals

Clock.R/W’: true when bus is reading.Address: a-bit bundle.Data: n-bit bundle.Data ready’.

Page 8: S emb t7-arch_bus

RMR©2012

Maths is not everything

© 2

008

Way

ne W

olf

Timing diagrams

time

A

B

C

zero

one

rising falling

stable

changing

10 ns

Page 9: S emb t7-arch_bus

RMR©2012

Maths is not everything

© 2

008

Way

ne W

olf

Typical bus timing for read

CPU:set R/W’=1;

asserts address, address enable.

Memory:asserts data;

asserts data ready’.

CPU:deasserts address, address enable.

Page 10: S emb t7-arch_bus

RMR©2012

Maths is not everything

© 2

008

Way

ne W

olf

Bus read state diagram

Getdata Done

Adrs

Wait

See ack

Page 11: S emb t7-arch_bus

RMR©2012

Maths is not everything

© 2

008

Way

ne W

olf

Transaction types

Wait state:state in a bus transaction to wait for acknowledgment.

Disconnected transfer:bus is freed during wait state.

Burst:multiple transfers.

Page 12: S emb t7-arch_bus

RMR©2012

Maths is not everything

Auxiliary MechanismsTimers

Page 13: S emb t7-arch_bus

RMR©2012

Maths is not everything

© 2

008

Way

ne W

olf

Timers and counters

Very similar:a timer is incremented by a periodic signal;

a counter is incremented by an asynchronous, occasional signal.

Rollover causes interrupt.

Page 14: S emb t7-arch_bus

RMR©2012

Maths is not everything

Timers

The main applications of timers are to:generate events of fixed time-period

allow periodic wakeup from sleep of the device

count transitional signal edges

replace delay loops allowing the CPU to sleep between operations, consuming less power

maintain synchronization clocks

14

Page 15: S emb t7-arch_bus

RMR©2012

Maths is not everything

Timers (MSP430)

System timing is fundamental for real-time applicationsThe MSP430F2274 has 2 timers, namely Timer_A and Timer_BThe timers may be triggered by internal or external clocksTimer_A and Timer_B also include multiple independent capture/compare blocks that are used for applications such as timed events and Pulse Width Modulation (PWM)

Page 16: S emb t7-arch_bus

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

(Used by Timer_B) TxSSELx IDx MCx - TxCLR TxIE TxIFG

Bit Description 9-8 TxSSELx Timer_x clock source: 0 0 ⇒ TxCLK

0 1 ⇒ ACLK 1 0 ⇒ SMCLK 1 1 ⇒ INCLK

7-6 IDx Clock signal divider: 0 0 ⇒ / 1 0 1 ⇒ / 2 1 0 ⇒ / 4 1 1 ⇒ / 8

5-4 MCx Clock timer operating mode: 0 0 ⇒ Stop mode 0 1 ⇒ Up mode 1 0 ⇒ Continuous mode 1 1 ⇒ Up/down mode

2 TxCLR Timer_x clear when TxCLR = 1

1 TxIE Timer_x interrupt enable when TxIE = 1

0 TxIFG Timer_x interrupt pending when TxIFG = 1

RMR©2012

Maths is not everything

Timers (MSP430) - TxCTL Control Register

Page 17: S emb t7-arch_bus

MCx Mode Description 0 0 Stop The timer is halted. 0 1 Up The timer repeatedly counts from 0x0000 to

the value in the TxCCR0 register. 1 0 Continuous The timer repeatedly counts from 0x0000 to

0xFFFF. 1 1 Up/down The timer repeatedly counts from 0x0000 to

the value in the TxCCR0 register and back down to zero.

RMR©2012

Maths is not everything

Timers (MSP430) - 4 Modes of Operation

Timer reset by writing a 0 to TxRClock timer operating modes:

Page 18: S emb t7-arch_bus

RMR©2012

Maths is not everything

Timers (MSP430) - Timer Modes

Up Mode

C o n t i n u o u s Mode

Up/Down Mode

Page 19: S emb t7-arch_bus

RMR©2012

Maths is not everything

Timers (MSP430): Timer_A Example

Use Timer A to interrupt every 1 msSMCLK .set 1200000 ; 1200000 clocks / secondTIME_1MS .set 1000 ; 1 ms = 1/1000 s

TA_CTL .set TASSEL_2+ID_0+MC_1+TAIE ; SMCLK, /1, UP, IETA_FREQ .set SMCLK/TIME_1MS ; clocks / 1 ms

clr.w &TAR ; reset timerA mov.w #TA_CTL,&TACTL ; set timerA control reg mov.w #TA_FREQ,&TACCR0 ; set interval (frequency) bis.w #LPM0+GIE,SR ; enter LPM0 w/interrupts jmp $ ; will never get here!

TA_isr: ; timer A ISR bic.w #TAIFG,&TACTL ; acknowledge interrupt; <<add interrupt code here>> reti

.sect ".int08" ; timer A section .word TA_isr ; timer A isr

Page 20: S emb t7-arch_bus

RMR©2012

Maths is not everything

© 2

008

Way

ne W

olf

Watchdog timer

Watchdog timer is periodically reset by system timer.If watchdog is not reset, it generates an interrupt to reset the host.

host CPU watchdogtimer

interrupt

reset

Page 21: S emb t7-arch_bus

RMR©2012

Maths is not everything

Watchdog Timer (MSP430)

The primary function of the watchdog timer+ (WDT+) module is to perform a controlled system restart after a software problem occurs.

If the selected time interval expires, a system reset is generated.

If the watchdog function is not needed in an application, the module can be configured as an interval timer and can generate interrupts at selected time intervals.

Page 22: S emb t7-arch_bus

RMR©2012

Maths is not everything

Watchdog Timer (MSP430)

Features of the watchdog timer+ module include:

Four software-selectable time intervals

Watchdog mode

Interval mode

Access to WDT+ control register is password protected

Control of RST/NMI pin function

Selectable clock source

Can be stopped to conserve power

Clock fail-safe feature

Page 23: S emb t7-arch_bus

RMR©2012

Maths is not everything

Watchdog Timer (MSP430) - Watchdog Power-up

After a power-up clear (PUC), the WDT+ module is automatically configured in the watchdog mode with an initial 32768 clock cycle reset interval using the DCOCLK.

The user must setup or halt the WDT+ prior to the expiration of the initial reset interval.

Page 24: S emb t7-arch_bus

RMR©2012

Maths is not everything

RESET: ! mov.w #0x0300,SP ; Initialize stack pointer ! mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop WDT ! bis.b #0x0f,&P1DIR ; Set P1.0-3 output ! mov.w #0,r14

...

Watchdog (MSP430) example: stoping it

In Assembly

In C

passwd = 0x5A

Page 25: S emb t7-arch_bus

RMR©2012

Maths is not everything

Auxiliary I/OButtons & Displays

Page 26: S emb t7-arch_bus

RMR©2012

Maths is not everything

© 2

008

Way

ne W

olf

Switch debouncing

A switch must be debounced to multiple contacts caused by eliminate mechanical bouncing:

Page 27: S emb t7-arch_bus

RMR©2012

Maths is not everything

© 2

008

Way

ne W

olf

Encoded keyboard

An array of switches is read by an encoder.N-key rollover remembers multiple key depressions.

row

Page 28: S emb t7-arch_bus

RMR©2012

Maths is not everything

© 2

008

Way

ne W

olf

LED

Must use resistor to limit current:

Page 29: S emb t7-arch_bus

RMR©2012

Maths is not everything

Auxiliary I/ODAC & ADC

Page 30: S emb t7-arch_bus

RMR©2012

Maths is not everything

© 2

008

Way

ne W

olf

Digital-to-analog conversion

Use resistor tree:R

2R

4R

8R

bn

bn-1bn-2bn-3

Vout

Page 31: S emb t7-arch_bus

RMR©2012

Maths is not everything

© 2

008

Way

ne W

olf

Flash A/D conversion

N-bit result requires 2n comparators:

encoder

Vin

...

Page 32: S emb t7-arch_bus

RMR©2012

Maths is not everything

© 2

008

Way

ne W

olf

Dual-slope conversion

Use counter to time required to charge/discharge capacitor.Charging, then discharging eliminates non-linearities.

Vin timer

Page 33: S emb t7-arch_bus

RMR©2012

Maths is not everything

© 2

008

Way

ne W

olf

Sample-and-hold

Required in any A/D:

converterVin