Microcontroller Applications Week 3 Lab 3 Dr. Bradley J. Bazuin Associate Professor Department of Electrical and Computer Engineering College of Engineering and Applied Sciences
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 2510 2
5X7 MATRIX DISPLAYS 3
Driving an LED Array Lighting One LED Source current to a row Selectively sink current from a column 20 ma, 2.1-2.6V 80 ma, 3.0-3.7V 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. Lite-On Technology Corp. LTP-757G 4
Sourcing Current to rows MIC5891YN IC DRVR LATCH 8BIT SER IN 16DIP - source Max Vce-sat 1.8 V @ 100 ma 2.0 V @ 350 ma 5
MIC5891YN Diagram Serial shifting of bits into the device 8-bit length, only 7 bits needed for matrix. 6
Operating the MIC5891YN A. Minimum data active time before clock pulse (data set-up time) 75ns B. Minimum data active time after clock pulse (data hold time) 75ns C. Minimum data pulse width.150ns D. Minimum clock pulse width 150ns E. Minimum time between clock activation and strobe 300ns F. Minimum strobe pulse width 100ns G. Typical time between strobe activation and output transition 1.0μs 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; if(bit_value == 0x01) PTP = 0x01; else PTP &= ~(0x01); asm( nop ); asm( nop ); PTP = 0x02; asm( nop ); asm( nop ); asm( nop ); asm( nop ); PTP &= ~(0x02); temp = temp>>1;}} \\ Determine value \\ Data output \\ setup > 75ns \\ clock high \\ pulse > 150 ns \\ clock low 8
Sinking Current ULN2803APG(O,N,HZN) IC DRIVER DARL 8CH 50V.5A 18DIP - sink Typ. Vce-sat 1.0 V @ 160 ma 0.75V @ 50 ma 9
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 Guessing for 80 ma 1.6V 3.0V 0.8V Total: 5.4V using a 5V supply! Likely to be < 80mA. 10
5x7 Matrix with Source and Sink ICs MIC5891 Source LTP-757G or similar Display ULN2803A Sink [note shown 74HCT595 shift reg.] (Future Sink: TPIC6C596N) 4510 11
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. 12
Logic for Selecting Columns 74HCT595: 8-bit serial-in, serial or parallel-out shift register with output latches; 3-state 13
Functional Table fmax clock high set-up hold prop 20 MHz max 24 ns min 24 ns min 3 ns min 63 ns max 14
Logical Operation 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 16
Bit Banging column shift register Using two cascaded 74HCT595 int jj; PTP = 0x10; \\ Set the one into the shift register PTP = 0x20; \\ shift register clock rise PTP & = ~(0x30); \\ shift register clock fall for (jj=0;jj<15;jj++) { row_load(rows_excited[jj+offset]); \\ load the row values PTP = 0x20; \\ shift register clock rise PTP &=~(0x80); \\ Output enable row and column PTP & = ~(0x20); \\ shift register clock fall delay(how long is the LED on) \\ one row of LEDs is on PTP = 0x80; \\ Output disable row and column } \\ next row/column 17
Light Patterns Storage for each pattern A: 0x1F, 0x24, 0x44, 0x24, 0x1F B: 0x7F, 0x49, 0x49, 0x49, 0x36 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. 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 register PTP = 0x20; \\ shift register clock rise PTP & = ~(0x30); \\ shift register clock fall 20