Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Programming for EEPROM IN PIC16F877A micrcontrollers

Status
Not open for further replies.

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
#1
Dear Friends, can you help me about internal/ external EEPROM programming in PIC16F877A microcontroller. I have written but it is not displaced in LCDs.



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
// 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:

  • Like
Reactions: tpetar

    tpetar

    Points: 2
    Helpful Answer Positive Rating
#4
Yes sir, i am using micro C as my compiler. and i am using external 24LCO4 EEPROM IC. so plz if you know for internal plz tell meexternal or
 

In My view you forgot to put Display LCD function in you code and in while(1) .....check that.....

Good luck
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top