Вы находитесь на странице: 1из 19

Drug Store Blood Pressure Meter

• Wait for button press


– Check safety measures
• Inflate pressure cuff
– Right pressure?
– Check safety
• Wait for first pressure pulse
– Wait too long -> deflate, message, error
– Capture systolic pressure
– Wait for next pulse, check elapsed time->measure pulse interval
– Wait for consecutive pulses
• Too much time -> capture diastolic pressure
• Check ranges
• Display result
– Re start
What a μController can do
• Control sequence – programming
• Keep track of time – timers
• Measure pressure – A/D converter
• Detect button presses, switch closures –
Digital Inputs
• Signal Process – simple math
• Display Results – send info to remote device
Digital Signals
 Two Levels
 0 and 1
 Typically 0 and 5 volts
 Logic functions
 AND, OR, NAND, NOR
 Logic Families
 TTL, LS, C, HC
 5V, 3.3V, 3V, 2.5V,1.8
 Need for speed
Binary Numbers
• Multiple binary bits
– Each bit is a pin or node with a 0 or 1 signal
• Characterized by word length
– 4,8,12,16,32,64 bits
– Number of unique numbers = 2n
• 4-16, 8-256, 12-4096, 16-65,536
• Intermediate complexity logic
– 74HC163 binary counter
– 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111
– 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111
– 0000,
74163 Data Sheet
Memory
Vcc, Vss: Power and Ground
A0-A16: Address (17)
W: Write
E1, E2: Enable
G: Output Enable
DQ0-DQ7: Data Bus (I/O)
Digital Latch Data Sheet
Binary, Octal, Hex
• 11001111 = 11 001 111 = 3178
• 01011010 = 0101 1010 = 5A16

• You will see a lot of hex


• 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
• D316 = 1101 0011 = 11010011
• = 13*16 + 3*1 = 21110
Process Control
Reset

Program
Oscillator
Counter
2 Add the numbers
1 Get 2nd number
0,1,2,3,…
0 Get 1st number

Program Memory
Central Processor

ALU
72 106
8 71 0x6A

W (working) Register 70 b01101100

Data Memory
Some Terminology
• Memory mapped I/O
– I/O devices programmed through memory locations
• Von Neumann vs Harvard
– Separate or combined program and data memory
• Instruction Pipeline
– A technique used speed processing by pre-fetching and
preprocessing instructions
• Flash vs RAM vs OTP
– Types of program memory
Memory in the PIC
• Data
Program
memory
memory
– Called
FLASHfiles (register files)
– RAM
16 bit instructions
– 8
32k
bitbytes long
– 16kbytes
• 1536 instructions
– Stores
• Stores
• Instructions
– Counters
– With constants
– Variables
• Tables
– Data – Made ahead of time
– • Data
Intermediate results
– Long access time
• Data Memory addresses also mapped to special function
registers
Special
Function
Registers

This is how
you ‘control’
devices in the
PIC
The Compiler

C- compiler

• Converts your text file (*.c) to a file that can


be assembled.
• Cross Compiler
• C Directives
• Your code
Timer
• A timer is a counter that counts fixed intervals
• The counters in the pic are (generally) 16 bits.
65,535 intervals
• For our clock, we want to keep track of seconds.
• If we use the CPU clock (4 Mhz) we would need
to count to 4 M.
• Instead, use a 2nd oscillator input to the PIC that
runs at 32,764 Hz. This is on the board, not the
PIC, but the PIC is designed to use it.

Вам также может понравиться