bikash123
Member level 2
- Joined
- Feb 19, 2012
- Messages
- 48
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- Tezpur University
- Activity points
- 1,672
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 // LCD module connections sbit LCD_RS at RB4_bit; sbit LCD_EN at RB5_bit; sbit LCD_D4 at RB0_bit; sbit LCD_D5 at RB1_bit; sbit LCD_D6 at RB2_bit; sbit LCD_D7 at RB3_bit; sbit LCD_RS_Direction at TRISB4_bit; sbit LCD_EN_Direction at TRISB5_bit; sbit LCD_D4_Direction at TRISB0_bit; sbit LCD_D5_Direction at TRISB1_bit; sbit LCD_D6_Direction at TRISB2_bit; sbit LCD_D7_Direction at TRISB3_bit; // End LCD module connections void WriteEEPROM(char Addr, char Data); char ReadEEPROM(char addr); void port_confg(); Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off void main() { char WriteEEPROM(char Addr, char Data); char ReadEEPROM(char addr); port_confg(); Delay_ms(2000); while(1) { } } void port_confg() { PORTB = 0; PORTA = 0; TRISB = 0b00001111; TRISA = 0b00100000; } char WriteEEPROM(char Addr, char Data) { while(EECON1.WR == 1); EEADR = Addr; EEDATA = Data; EECON1.EEPGD = 0; // 0 = Access data EEPROM memory EECON1.WREN = 1; // enable writes to internal EEPROM EECON2 = 0x55; // Required sequence for write to internal EEPROM EECON2 = 0xAA; // Required sequence for write to internal EEPROM EECON1.WR = 1; // begin write to internal EEPROM EECON1.WREN = 0; } char ReadEEPROM(char addr) { EEADR = addr; EECON1.EEPGD = 0; EECON1.RD = 1; asm nop; asm nop; return EEDATA; }
Last edited by a moderator: