Upload
others
View
11
Download
0
Embed Size (px)
Citation preview
ECE 4510/5530Microcontroller Applications
Week 3 Lab 3
Dr. Bradley J. BazuinAssociate Professor
Department of Electrical and Computer EngineeringCollege of Engineering and Applied Sciences
ECE 2510 2
Lab 3 Elements
• Hardware Development– Clock-recovery-generator (CRG) (Chap. 6.6, 6.7) – 5 x 7 Matrix Display (Chap. 7.9)– Enhanced Capture Timer (ECT) (Chap. 8)
• Software Development Environment– Interrupts (Chap. 6.2, 6.5) – CRG_sw
5X7 MATRIX DISPLAYS
ECE 4510/5530
3
Driving an LED Array
Lighting One LED• Source current to a row• Selectively sink current
from a column
Matrix Driving• Separately source all rows
where LEDs are to turn on in Column 1 AND sink current from only column 1.
• Do the next column … and repeat.ECE
4510/55304Lite-On Technology Corp. LTP-757G
20 mA, 2.1-2.6V80 mA, 3.0-3.7V
Sourcing Current to rows
• MIC5891YN• IC DRVR LATCH 8BIT SER IN 16DIP - source
ECE 4510/5530
5
Max Vce-sat1.8 V @ 100 mA2.0 V @ 350 mA
MIC5891YN Diagram
• Serial shifting of bits into the device– 8-bit length, only 7 bits needed for matrix.
ECE 4510/5530
6
Operating the MIC5891YN
A. Minimum data active time before clock pulse (data set-up time) 75nsB. Minimum data active time after clock pulse (data hold time) 75nsC. Minimum data pulse width .150nsD. Minimum clock pulse width 150nsE. Minimum time between clock activation and strobe 300nsF. Minimum strobe pulse width 100nsG. Typical time between strobe activation and output transition 1.0μs
ECE 4510/5530
7
Bit Banging MIC row data
• Using software and individual bit-level ports to create a more complex signaling stream (PTP.0 data, PTP.1 clock)
row_load(rows_excited[jj]);void row_load(char temp){int ii;for (ii=0;ii<8;ii++) {
bit_value = temp & 0x01; \\ Determine valueif(bit_value == 0x01) PTP |= 0x01; \\ Data outputelse PTP &= ~(0x01);asm(“nop”); \\ setup > 75nsasm(“nop”);PTP |= 0x02; \\ clock highasm(“nop”); \\ pulse > 150 nsasm(“nop”);asm(“nop”);asm(“nop”);PTP &= ~(0x02); \\ clock lowtemp = temp>>1;}}
ECE 4510/5530
8
Sinking Current
• ULN2803APG(O,N,HZN)• IC DRIVER DARL 8CH 50V .5A 18DIP - sink
ECE 4510/5530
9
Typ. Vce-sat1.0 V @ 160 mA0.75V @ 50 mA
Voltage and current check
• Source– Max Vce-sat– 1.8 V @ 100 mA– 2.0 V @ 350 mA
• LED– 20 mA, 2.1-2.6V– 80 mA, 3.0-3.7V
• Sink– Typ. Vce-sat– 1.0 V @ 160 mA– 0.75V @ 50 mA
ECE 4510/5530
10
Guessing for 80 mA1.6V3.0V0.8V
Total: 5.4V … using a 5V supply!
Likely to be < 80mA.
5x7 Matrix with Source and Sink ICs
ECE 4510 11
MIC5891 SourceLTP-757G or similar DisplayULN2803A Sink[note shown 74HCT595 shift reg.]
(Future Sink: TPIC6C596N)
Driving Column Data
• For 3- 5x7 matrix displays there are 7 rows and 15 columns– Define a base period and divide by 16 … 15 for display, 1 for
recovery– Each column driven on one clock cycle …. serially.
ECE 4510/5530
12
Logic for Selecting Columns
• 74HCT595: 8-bit serial-in, serial or parallel-out shift register with output latches; 3-state
ECE 4510/5530
13
Functional Table
ECE 4510/5530
14
fmax 20 MHz maxclock high 24 ns minset-up 24 ns minhold 3 ns minprop 63 ns max
Logical Operation
ECE 4510/5530
15
What do we need?
• We want a “walking” column select.– load a one followed by all zeros.– Every clock moves the one through the shift register– After 16 clocks … the one is gone
ECE 4510/5530
16
Bit Banging column shift register
• Using two cascaded 74HCT595
int jj;PTP |= 0x10; \\ Set the one into the shift registerPTP | = 0x20; \\ shift register clock risePTP & = ~(0x30); \\ shift register clock fallfor (jj=0;jj<15;jj++) {
row_load(rows_excited[jj+offset]); \\ load the row valuesPTP | = 0x20; \\ shift register clock risePTP &=~(0x80); \\ Output enable row and columnPTP & = ~(0x20); \\ shift register clock falldelay(how long is the LED on) \\ one row of LEDs is onPTP |= 0x80; \\ Output disable row and column} \\ next row/column
ECE 4510/5530
17
Light Patterns
• Storage for each pattern– A: 0x1F, 0x24, 0x44, 0x24, 0x1F– B: 0x7F, 0x49, 0x49, 0x49, 0x36
ECE 4510/5530
18
Display Array
• Construct a memory space– 5 bytes per display character, 9 characters
• 3 blanks, 3 to display, and 3 blanks• use an offset into the array to select the first column (jj+offset)
– The offset allows you to “shift the text” right or left
• When you know the number or character to display, load the 5-chars for it’s display into consecutive memory locations of the memory space. – by sequentially displaying the 5 columns, the number/letter should
appear.
ECE 4510/5530
19
Rethinking the code
• What was described does not allow anything else to happen … so– Construct code to send the column and turn one column of LEDs
on … this is where the delay would com in– Construct code to turn off the LEDs (using the output enables)– Use a timer flag to turn off LED and then turns on the next column
if(matrix_flag){disable_matrix_LEDs();enable_next_matrix_column(offset+jj);jj++;if(jj==15){
jj=0;PTP |= 0x10; \\ Set the one into the shift registerPTP | = 0x20; \\ shift register clock risePTP & = ~(0x30); \\ shift register clock fall
}ECE 4510/5530
20