Devry University - ECET 340: LAB#2 Keypad-LCD PROGRAMMING KEYPAD ON TWR-DEV-PERIPH.
Devry University - ECET 340: LAB#2 Keypad-LCD PROGRAMMING KEYPAD ON TWR-DEV-PERIPH. do{ mSDelay(15); PORTA = PORTA | 0x0F; //COLUMNS SET HIGH row = PORTA & 0xF0; //READ ROWS }while(row != 0x00); //MAKE SURE BUTTON IS NOT STILL HELD } //CLOSE WHILE(1) } //CLOSE MAIN /**********************SUBROUTINES***********/ void mSDelay(unsigned int itime){ unsigned int i; unsigned int j; for(i=0;i<itime;i++) for(j=0;j<1000;j++); } Lab Manual for “HCS12 Microcontroller and Embedded Systems” LAB#2 Keypad-LCD WORKSHEET ACTIVITY 2 Repeat Activity 1 to display the characters on LCD. Use the LCD program in Lab1A_LCD #include <hidef.h> /* common defines and macros */ #include "derivative.h" /* derivative-specific definitions */ #define LCD_DATA PORTC #define LCD_CTRL PORTC #define RS 0x01 // PORTCo for RS pin of LCD #define EN 0x04 // PORTC2 for en pin of LCd void COMWRT4(unsigned char); void DATWRT4(unsigned char); void mSDelay(unsigned int); const unsigned char keypad[4][4] = { 0x31,0x32,0x33,0x41, 0x34,0x35,0x36,0x42, 0x37,0x38,0x39,0x43, 0x2A,0x30,0x23,0x44 //Notice 0x2A is ASCII for '*' and 0x23 for '#' }; unsigned char column,row,mykey; /**************MAIN*******************************/ void main(void){ //OPEN MAIN DDRA = 0x0F; DDRC = 0xFF; //PORTC=output for data and control signals DDRB = DDRB | 0x80; //PB7 as output PORTB = PORTB & 0x7F; //PB7=0 for CSB pin of LCD DDRP = DDRP | 1; //PORTP7 as output for backlight control PTP = PTP | 1; //turn on the backlight (optional) PORTC =0x0; mSDelay(10); //Many of the initialization commmands of ST7036 LCD is the same as HD44780 covered in the Mazidi/Causey textbook. //However, for ST7034-bases LCD we need few more commands. See Page 42 of ST7036 datasheet COMWRT4(0x33); mSDelay(1); COMWRT4(0x32); mSDelay(1); COMWRT4(0x29); //Function set:DL=0(4-bit) This option is compatibe Lab Manual for “HCS12 Microcontroller and Embedded Systems”
Written for
- Institution
- Devry University
- Module
- ECET 340
Document information
- Uploaded on
- August 24, 2021
- Number of pages
- 16
- Written in
- 2021/2022
- Type
- Other
- Person
- Unknown
Subjects
-
devry university ecet 340 lab2 keypad lcd programming keypad on twr dev periph
-
lab2 keypad lcd programming keypad on twr dev periph
-
ecet 340 lab2 keypad lcd programming keypad on twr dev periph