EEprom Not reading data Properly....

Thread Starter

kishore486

Joined Mar 1, 2016
3
Hi, i am not good in English ..hope u understand but ,here i am working on LPC1778 .. here i am using EEPROM to store some data in there respective addresses .. Writing into EEPROM have no problem but while reading the values are interchange was happen ...why it is reading like that ...guys i am new to EEPROM Plz suzzez me..
 

Picbuster

Joined Dec 2, 2013
1,044
Please tell us more like ;
schematic
your program
measured timing diagram.
model & type eeprom
how do you know that writing is ok it might left the mpu and arrives ok but is it correctly stored?
 

Thread Starter

kishore486

Joined Mar 1, 2016
3
Thanks for reply,
My code was Attached below check once. i checked in debug mode in that EEPROM WRITING operation working properly by at the time of reading only getting special symbols at the position of 2,4,... . i written code for LPC1778 Internal EEPROM.
Code:
#include <LPC177x_8x.H>

#include "EEPROM.h"
void Port_Init(void);
unsigned int i,flag,count;
//  unsigned char E_Wdata[]="486";
int main()
{
    SystemInit();
    Port_Init();
    Timer_Init();
    LCD_Init();
    EEPROM_Init();
//    
//         E_Wdata[i]=i;
   
    Write_EEPROM(CMD_WR8,0x00,"999999");
    PROG_EEPROM(CMD_E_P_Mem,0x00);
    Read_EEPROM(0x00);
    while(1)
    {
       
       
    }
}

void Port_Init(void)
{
    LPC_IOCON->P1_0      = 0x00000000;
    LPC_IOCON->P0_0            =    0x00000000;
    LPC_IOCON->P0_1            =    0x00000000;
    LPC_IOCON->P0_2            =    0x00000000;
    LPC_IOCON->P0_3            =    0x00000000;
    LPC_IOCON->P0_4            =    0x00000000;
    LPC_IOCON->P0_5            =    0x00000000;
    LPC_IOCON->P0_6            =    0x00000000;
    LPC_IOCON->P0_7            =    0x00000000;
    LPC_IOCON->P0_8            =    0x00000000;
    LPC_IOCON->P0_9            =    0x00000000;
    LPC_IOCON->P0_10        =    0x00000000;
    LPC_GPIO0->DIR            =    0x000007FF;
       
}
void Delay_ms(unsigned int time)
{
    flag=1;
    while(count!=time);
    flag=0;
    count=0;
}

/*****EEPROM CODE*******/
void EEPROM_Init()
{
    LPC_EEPROM->PWRDWN=0x00000000;             //not in power down mode.
    LPC_EEPROM->CLKDIV=320;

}

void Read_EEPROM(unsigned char cmd)
{
    E_Rdata=EEPROM_Read(CMD_R8,cmd);
    LCD_StrSend(E_Rdata,0x80);
//     k=atoi(E_Rdata);

//     l=atoi(E_Rdata[1]);
   
}

void Write_EEPROM(unsigned char cmd,unsigned char addr, unsigned char *data)
{
    unsigned int i;
    LPC_EEPROM->CMD = cmd;
    LPC_EEPROM->ADDR=(addr<<6);
  for(i=0;i<8;i++)
  {
        LPC_EEPROM->CMD = cmd;
        LPC_EEPROM->WDATA  = *(data++);
        while(!(LPC_EEPROM->INT_STATUS&(1<<26)));
        LPC_EEPROM->INT_CLR_STATUS=(1<<26);
    }

   
}
void PROG_EEPROM(unsigned char cmd,unsigned char addr)
{
    LPC_EEPROM->CMD=cmd;
    LPC_EEPROM->ADDR=(addr<<6);
    while(!(LPC_EEPROM->INT_STATUS&(1<<28)));
    LPC_EEPROM->INT_CLR_STATUS=(1<<28);   
//     EEPROM_Prog(CMD_E_P_Mem,0x00); 
}

unsigned char* EEPROM_Read(unsigned char cmd,unsigned char addr)
{
  unsigned int i;
    LPC_EEPROM->CMD=cmd;
    LPC_EEPROM->ADDR=(addr<<6);   
    for(i=0;i<8;i++)
    {
      LPC_EEPROM->CMD=cmd;
      r_data[i]=LPC_EEPROM->RDATA;
       
        while(!(LPC_EEPROM->INT_STATUS&(1<<26)));
      LPC_EEPROM->INT_CLR_STATUS=(1<<26);
     }
    return r_data;
}
 

Picbuster

Joined Dec 2, 2013
1,044
Thanks for reply,
My code was Attached below check once. i checked in debug mode in that EEPROM WRITING operation working properly by at the time of reading only getting special symbols at the position of 2,4,... . i written code for LPC1778 Internal EEPROM.
Code:
#include <LPC177x_8x.H>

#include "EEPROM.h"
void Port_Init(void);
unsigned int i,flag,count;
//  unsigned char E_Wdata[]="486";
int main()
{
    SystemInit();
    Port_Init();
    Timer_Init();
    LCD_Init();
    EEPROM_Init();
//   
//         E_Wdata[i]=i;
  
    Write_EEPROM(CMD_WR8,0x00,"999999");
    PROG_EEPROM(CMD_E_P_Mem,0x00);
    Read_EEPROM(0x00);
    while(1)
    {
      
      
    }
}

void Port_Init(void)
{
    LPC_IOCON->P1_0      = 0x00000000;
    LPC_IOCON->P0_0            =    0x00000000;
    LPC_IOCON->P0_1            =    0x00000000;
    LPC_IOCON->P0_2            =    0x00000000;
    LPC_IOCON->P0_3            =    0x00000000;
    LPC_IOCON->P0_4            =    0x00000000;
    LPC_IOCON->P0_5            =    0x00000000;
    LPC_IOCON->P0_6            =    0x00000000;
    LPC_IOCON->P0_7            =    0x00000000;
    LPC_IOCON->P0_8            =    0x00000000;
    LPC_IOCON->P0_9            =    0x00000000;
    LPC_IOCON->P0_10        =    0x00000000;
    LPC_GPIO0->DIR            =    0x000007FF;
      
}
void Delay_ms(unsigned int time)
{
    flag=1;
    while(count!=time);
    flag=0;
    count=0;
}

/*****EEPROM CODE*******/
void EEPROM_Init()
{
    LPC_EEPROM->PWRDWN=0x00000000;             //not in power down mode.
    LPC_EEPROM->CLKDIV=320;

}

void Read_EEPROM(unsigned char cmd)
{
    E_Rdata=EEPROM_Read(CMD_R8,cmd);
    LCD_StrSend(E_Rdata,0x80);
//     k=atoi(E_Rdata);

//     l=atoi(E_Rdata[1]);
  
}

void Write_EEPROM(unsigned char cmd,unsigned char addr, unsigned char *data)
{
    unsigned int i;
    LPC_EEPROM->CMD = cmd;
    LPC_EEPROM->ADDR=(addr<<6);
  for(i=0;i<8;i++)
  {
        LPC_EEPROM->CMD = cmd;
        LPC_EEPROM->WDATA  = *(data++);
        while(!(LPC_EEPROM->INT_STATUS&(1<<26)));
        LPC_EEPROM->INT_CLR_STATUS=(1<<26);
    }

  
}
void PROG_EEPROM(unsigned char cmd,unsigned char addr)
{
    LPC_EEPROM->CMD=cmd;
    LPC_EEPROM->ADDR=(addr<<6);
    while(!(LPC_EEPROM->INT_STATUS&(1<<28)));
    LPC_EEPROM->INT_CLR_STATUS=(1<<28);  
//     EEPROM_Prog(CMD_E_P_Mem,0x00);
}

unsigned char* EEPROM_Read(unsigned char cmd,unsigned char addr)
{
  unsigned int i;
    LPC_EEPROM->CMD=cmd;
    LPC_EEPROM->ADDR=(addr<<6);  
    for(i=0;i<8;i++)
    {
      LPC_EEPROM->CMD=cmd;
      r_data[i]=LPC_EEPROM->RDATA;
      
        while(!(LPC_EEPROM->INT_STATUS&(1<<26)));
      LPC_EEPROM->INT_CLR_STATUS=(1<<26);
     }
    return r_data;
}
  1. LPC_EEPROM->CMD=cmd;
  2. r_data=LPC_EEPROM->RDATA;
    [*] <<<<<<<<<<<<<<<<<<<<<< try this output here in hex or decimal LPC_EEPROM->RDATA;
    [*] while(!(LPC_EEPROM->INT_STATUS&(1<<26)));
    [*] LPC_EEPROM->INT_CLR_STATUS=(1<<26);
 
Top