DOC PREVIEW
U of U ECE 3720 - Output LEDs and LCDs
Pages 10

This preview shows page 1-2-3 out of 10 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1'&$%ECE/CE 3720: Embedded System DesignChris J. MyersLecture 17: Output LEDs and LCDsSlide 2'&$%Interfacing Multiple LEDs1Slide 3'&$%Single LED InterfaceSlide 4'&$%Output Param. for Open-Collector/Emitter Gates(See Tables 8.4 and 8.5)2Slide 5'&$%Typical Voltage/Current Response of a LEDParameter red green yellow orange unitsMax power 55 75 60 75 mWPeak current 160 100 80 100 mAMax current 25 25 20 25 mASlide 6'&$%Calculating the Resistor Value3Slide 7'&$%Seven-Segment LED Interfaces (Common-Cathode)Slide 8'&$%Seven-Segment LED Interfaces (Common-Anode)4Slide 9'&$%Scanned Seven-Segment LED InterfaceSlide 10'&$%Circuit Used to Scan a LED Interface5Slide 11'&$%Software for Scanned LED Display// PB7-PB0 output, 7 bit pattern// PC2-PC0 output, selects LED digitunsigned char code[3]; // binary codesstatic unsigned char select[3]={4,2,1};unsigned int index; // 0,1,2#define OC5F 0x08void ritual(void) {asm(" sei"); // make atomicindex=0;DDRC=0xFF; // outputsTMSK1|=OC5F; // Arm OC5TFLG1=OC5F; // clear OC5FTOC5=TCNT+10000;asm(" cli"); }Slide 12'&$%Software for Scanned LED Display#pragma interrupt_handler TOC5handler()void TOC5handler(void){TFLG1=OC5F; // AcknowledgeTOC5=TOC5+10000; // every 5 msPORTC=select[index]; // which LED?PORTB=code[index]; // enableif(++index==3) index=0;}6Slide 13'&$%Scanned LED Interface Using DecoderSlide 14'&$%Software for Multiplexed LED Displayunsigned int global; // 12 bit packed BCDconst struct LED{ unsigned char enable; // selectunsigned char shift; // bits to shiftconst struct LED *Next; }; // Link#typedef const struct LED LEDType;#typedef LEDType * LEDPtr;LEDType LEDTab[3]={{ 0x04, 8, &LEDTab[1] }, // Most sig{ 0x02, 4, &LEDTab[2] },{ 0x01, 0, &LEDTab[0] }}; // least sigLEDPtr Pt; // Points to current digit#define OC5F 0x087Slide 15'&$%Software for Multiplexed LED Display#pragma interrupt_handler TOC5handler()void TOC5handler(void){TFLG1=OC5F; // AcknowledgeTOC5=TOC5+10000; // every 5 msPORTB=(Pt->enable)+(global>>(pt->shift))<<4);Pt=Pt->Next; }void ritual(void) {asm(" sei"); // make atomicglobal=0;TMSK1=OC5F; // Arm OC5Pt=&LEDTab[0];TFLG1=OC5F; // clear OC5F */TOC5=TCNT+10000;asm(" cli"); }Slide 16'&$%Extensions to Multiple Digits• Two issues to consider as number of digits is increased:1. Scan frequency - for display to “look” continuous,each digit must be updated faster than 60 Hz.– interrupt rate = 60 Hz × #digits2. Duty cycle - this decreases as digits added, so mustincrease instantaneous current.– instantaneous current = desired current × #digits• Ratio of maximum instantaneous current to desired LEDcurrent determines maximum number of digits.8Slide 17'&$%Integrated IC Interface for LED DigitsSlide 18'&$%Data Timing of Integrated LED Controller9Slide 19'&$%Software for Integrated LED Display// PD3/MOSI = MC14489 DATA IN// PD4/SCLK = MC14489 CLOCK IN// PD5 (simple output) = MC14489 ENABLEvoid ritual(void) {DDRD |= 0x38; // outputs to MC14489SPCR=0x50;PORTD|= 0x20; // ENABLE=1PORTD&= 0xDF; // ENABLE=0SPDR=0x01; // hex formatwhile(SPSR&0x80)==0){};PORTD|=0x20;} // ENABLE=1Slide 20'&$%Software for Integrated LED Displayvoid LEDout(unsigned char data[3]){// 24 bit packed BCDPORTD &= 0xDF; // ENABLE=0SPDR = data[2]; // send MSbytewhile(SPSR&0x80)==0){};SPDR = data[1]; // send middle bytewhile(SPSR&0x80)==0){};SPDR = data[0]; // send LSbytewhile(SPSR&0x80)==0){};PORTD |= 0x20;} // ENABLE=110Slide 21'&$%LCD Fundamentals• LCD display consume less power than LED displays.• LCDs are more flexible in sizes and shapes, allowing forcombination of numbers, letters, words, and graphics.• Uses liquid-crystal material that behaves as a capacitor.• While LED converts electric power to emitted opticalpower, LCD uses AC voltage to change light reflectivity.• Light energy is supplied by room or separate back light.• Display controlled by altering reflectivity of each segment.• Disadvantage is that they have slow response time, buttypically fast enough for human perception.Slide 22'&$%Basic Idea of a Liquid Crystal Interface11Slide 23'&$%Direct Interface of a LCDSlide 24'&$%Helper Function for a Simple LCD Displayvoid LCDOutDigit(unsigned char position,unsigned char data) {// position is 0x80, 0x40, 0x20, or 0x10// and data is the BCD digit// set BCD digit on A-D inputs of the MC14543BPORTB=0x0F&data;// toggle one of the LD inputs highPORTB|=position;// LD=0, latch digit into MC14543BPORTB=0x0F&data;}12Slide 25'&$%Software Interface for a Simple LCD Displayvoid LCDOutNum(unsigned int data){unsigned int digit,num,i;unsigned char pos;// data should be unsigned from 0 to 9999num=min(data,9999);pos=0x10; // position of first digit (ones)for(i=0;i<4;i++){// next BCD digit 0 to 9digit=num%10; num=num/10;LCDOutDigit(pos,digit); pos=pos<<1;}}Slide 26'&$%Latched Interface of a LCD13Slide 27'&$%Artwork for 8-Segment LCD DigitsSlide 28'&$%LCD Timing14Slide 29'&$%LCD Timing (cont)Slide 30'&$%Interface of a 48-Segment LCD Display15Slide 31'&$%Bit-Banged Interface to a Scanned LCD Displayvoid LCDOut (unsigned char *pt) {unsigned int i;unsigned char mask;for(i=0;i<6;i++){// look at bits 7,6,5,4,3,2,1,0for(mask=0x80;mask;mask=mask>>1){if((*pt)&mask) PORTB=1;else PORTB=0; // Serial data of the MC145000PORTB|=2; // toggle the serial clock highPORTB&=0xFD;} // then lowpt++; }}Slide 32'&$%SPI Interface to a Scanned LCD Display// PD3/MOSI = MC145000 DATA IN// PD4/SCLK = MC145000 CLOCK INvoid ritual(void) {DDRD |= 0x18; // outputs to MC145000SPCR=0x50; }void LCDout(unsigned char data[6]){unsigned int j;for(j=5; j>=0 ; j--){SPDR = data[j]; // Msbyte firstwhile(SPSR&0x80)==0){};}}16Slide 33'&$%Interface of a HD44780 LCD ControllerRS R/W Cycle0 0 Write to instruction register0 1 Read busy flag (bit 7)1 0 Write data from µ-procesor to HD447801 1 Read data from HD44780 to µ-processorSlide 34'&$%Private Functions for LCD Display// 1 by 16 char LCD Display (HD44780)#define LCDdata 1 // PB0=RS=1#define LCDcsr 0 // PB0=RS=0#define LCDread 2 // PB1=R/W=1#define LCDwrite 0 // PB1=R/W=0#define LCDenable 4 // PB2=E=1#define LCDdisable 0 // PB2=E=0void LCDcycwait(unsigned short cycles){TOC5=TCNT+cycles; // 500ns cyclesTFLG1 = 0x08; // clear C5Fwhile((TFLG1&0x08)==0){};}17Slide 35'&$%Public Functions for LCD Displayvoid LCDinit(void){DDRC=0xFF;LCDputcsr(0x06);// I/D=1 Increment, S=0 nodisplayshiftLCDputcsr(0x0C); // D=1 displayon,// C=0 cursoroff, B=0 blinkoffLCDputcsr(0x14); // S/C=0 cursormove, R/L=0 shiftrightLCDputcsr(0x30);// DL=1 8bit, N=0 1 line, F=0


View Full Document

U of U ECE 3720 - Output LEDs and LCDs

Course: Ece 3720-
Pages: 10
Download Output LEDs and LCDs
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Output LEDs and LCDs and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Output LEDs and LCDs 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?