M4
M4
M4
Hardware/Software Introduction
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
failure, self-reset
• Another use: timeouts /* main.c */ watchdog_reset_routine(){
/* checkreg is set so we can load value into
main(){ timereg. Zero is loaded into scalereg and
– e.g., ATM machine wait until card inserted 11070 is loaded into timereg */
call watchdog_reset_routine
– 16-bit timer, 2 checkreg = 1
microsec. resolution while(transaction in progress){ scalereg = 0
if(button pressed){ timereg = 11070
– timereg value = 2*(216- perform corresponding action }
call watchdog_reset_routine
1)–X = 131070–X } void interrupt_service_routine(){
– For 2 min., X = eject card
/* if watchdog_reset_routine not called every reset screen
120,000 microsec. < 2 minutes, interrupt_service_routine is }
called */
}
When
Osc freq: Divides the 11-bit up overflow
12 MHz = frequency by counter, occurs, it
12 means roll over to
12 X 10 6 adds the 16-bit up
0 again and
after every counter give signal checkreg counter, adds the
12 clock value up to timereg,
enables or counter value up
cycles, clk is after every overflow
generated 1 clk signal occurs
disable the timer after every 2 ms
when scale by controlling overflow trigger
reg counts timereg register, signal, when
cycle = (all to reset the timereg counts
timer, checkreg (all 1s)2
16
1s) 211
must be enabled
error checking
• Start bit, stop bit
• Baud rate
– signal changes per second
– bit rate usually higher 1 0 0 1 1 0 1 1
% of Maximum
Input Voltage RPM of DC Motor
Voltage Applied
0 0 0
2.5 50 1840
3.75 75 6900
/* controls period */
PWMP = 0xff; // clk_div
/* controls duty cycle */
PWM1 = 0x7f; //cycle_high
while(1){}; From
} processor DC
MOTOR
CODES RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Description
I/D = 1 cursor moves left DL = 1 8-bit
0 0 0 0 0 0 0 0 0 1 Clears all display, return cursor home
I/D = 0 cursor moves right DL = 0 4-bit
S = 1 with display shift N = 1 2 rows 0 0 0 0 0 0 0 0 1 * Returns cursor home
S/C =1 display shift N = 0 1 row
Sets cursor move direction and/or
0 0 0 0 0 0 0 1 I/D S
S/C = 0 cursor movement F = 1 5x10 dots specifies not to shift display
R/L = 1 shift to right F = 0 5x7 dots ON/OFF of all display(D), cursor
0 0 0 0 0 0 1 D C B
ON/OFF (C), and blink position (B)
R/L = 0 shift to left
0 0 0 0 0 1 S/C R/L * * Move cursor and shifts display
0x014
8 2x20
0x38 0x040
• Driver HD77480
– Three control signals:
• RS – Register Select (RA3)
• R/W – Read/Write (RA2)
• E – Enable (RA1)
– Three power connections
• Power, ground, and the variable register to control the brightness
IR REGISTER
DR REGISTER
Embedded Systems Design: A Unified
Hardware/Software Introduction, (c) 2000 Vahid/Givargis
Command and Instruction set for
LCD type HD44780
• Software
– To write into the LCD, the program should:
• Send the initial instructions (commands) before it can check DB7
to set up the LCD in the 4-bit or the 8-bit mode.
• Check DB7 and continue to check until it goes low.
• Write instructions to IR to set up the LCD parameters such as the
number of display lines and cursor status.
• Write data to display a message.
N1
N2
N3 k_pressed
N4
M1
M2
M3
M4 4
key_code key_code
keypad controller
N=4, M=4
Red A
White A’
Yellow B
Black B’
Sampling at 8X
Signal Frequency
Sampling at 2X
Signal Frequency
Sampling less
than 2X Signal
Frequency
0
Vin lies in between Vcomp5 & Vcomp6
Vcomp5 = Vref*5/8 = 5V
0
Vcomp6 = Vref*6/8 = 6V 1
1
Advantages Disadvantages
• Very fast • Needs many parts
(255 comparators
for 8-bit ADC)
• Lower resolution
• Expensive
• Large power
consumption
Embedded Systems Design: A Unified 101
Hardware/Software Introduction, (c) 2000 Vahid/Givargis
Successive Approximation ADC
4V
6V
5V
Successive-approximation method