renuka gurmeet singh
Junior Member level 2
- Joined
- Jun 7, 2014
- Messages
- 20
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 132
Please help me to correct this code.Thanks in advance.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 #include<htc.h> #define _16F877 #define XTAL_FREQ 12MHZ __CONFIG( FOSC_HS & WDTE_OFF & PWRTE_ON & CP_OFF & BOREN_ON & LVP_OFF & CPD_OFF & DEBUG_OFF); #define lcd_port PORTD #define LCD_EN RB1 #define LCD_RS RB0 /////////////////////delay routine/////////////////////////////////// void delay(unsigned int temp) { while(temp!=0) { temp--; } } /////////////////////main program/////////////////////////////////////// void lcd_cmd (unsigned char cmd) { delay(40); LCD_RS=0; lcd_port=((cmd>>4)&0x0F); LCD_EN=1; delay(50); LCD_EN=0; lcd_port=(cmd & 0x0F); LCD_EN=1; delay(50); LCD_EN=0; } void lcd_data (unsigned char dat) { delay(40); LCD_RS=1; lcd_port=((dat>>4)&0x0F); LCD_EN=1; delay(50); LCD_EN=0; lcd_port=(dat & 0x0F); LCD_EN=1; delay(50); LCD_EN=0; } void lcd_string(unsigned char *str) { while(*str) lcd_data(*str++); delay(300); } void lcd_init () { lcd_cmd (0x28); // 4-bit mode - 2 line - 5x7 font. lcd_cmd (0x0C); // Display no cursor - no blink. lcd_cmd (0x06); // Automatic Increment - No Display shift. lcd_cmd (0x80); // Address DDRAM with 0 offset 80h. } void main(void) { TRISD=0x00; TRISB0=0; TRISB1=0; delay(200); lcd_init (); lcd_cmd (0x81); lcd_data("hvvv"); lcd_cmd (0xc1); lcd_data("g"); // while(1); }
Last edited by a moderator: