EEprom Not reading data Properly....

Discussion in 'Embedded Systems and Microcontrollers' started by kishore486, Mar 1, 2016.

  1. kishore486

    Thread Starter New Member

    Mar 1, 2016
    3
    0
    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..
     
  2. Picbuster

    Member

    Dec 2, 2013
    374
    50
    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?
     
  3. kishore486

    Thread Starter New Member

    Mar 1, 2016
    3
    0
    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 (Text):
    1. #include <LPC177x_8x.H>
    2.  
    3. #include "EEPROM.h"
    4. void Port_Init(void);
    5. unsigned int i,flag,count;
    6. //  unsigned char E_Wdata[]="486";
    7. int main()
    8. {
    9.     SystemInit();
    10.     Port_Init();
    11.     Timer_Init();
    12.     LCD_Init();
    13.     EEPROM_Init();
    14. //    
    15. //         E_Wdata[i]=i;
    16.    
    17.     Write_EEPROM(CMD_WR8,0x00,"999999");
    18.     PROG_EEPROM(CMD_E_P_Mem,0x00);
    19.     Read_EEPROM(0x00);
    20.     while(1)
    21.     {
    22.        
    23.        
    24.     }
    25. }
    26.  
    27. void Port_Init(void)
    28. {
    29.     LPC_IOCON->P1_0      = 0x00000000;
    30.     LPC_IOCON->P0_0            =    0x00000000;
    31.     LPC_IOCON->P0_1            =    0x00000000;
    32.     LPC_IOCON->P0_2            =    0x00000000;
    33.     LPC_IOCON->P0_3            =    0x00000000;
    34.     LPC_IOCON->P0_4            =    0x00000000;
    35.     LPC_IOCON->P0_5            =    0x00000000;
    36.     LPC_IOCON->P0_6            =    0x00000000;
    37.     LPC_IOCON->P0_7            =    0x00000000;
    38.     LPC_IOCON->P0_8            =    0x00000000;
    39.     LPC_IOCON->P0_9            =    0x00000000;
    40.     LPC_IOCON->P0_10        =    0x00000000;
    41.     LPC_GPIO0->DIR            =    0x000007FF;
    42.        
    43. }
    44. void Delay_ms(unsigned int time)
    45. {
    46.     flag=1;
    47.     while(count!=time);
    48.     flag=0;
    49.     count=0;
    50. }
    51.  
    52. /*****EEPROM CODE*******/
    53. void EEPROM_Init()
    54. {
    55.     LPC_EEPROM->PWRDWN=0x00000000;             //not in power down mode.
    56.     LPC_EEPROM->CLKDIV=320;
    57.  
    58. }
    59.  
    60. void Read_EEPROM(unsigned char cmd)
    61. {
    62.     E_Rdata=EEPROM_Read(CMD_R8,cmd);
    63.     LCD_StrSend(E_Rdata,0x80);
    64. //     k=atoi(E_Rdata);
    65.  
    66. //     l=atoi(E_Rdata[1]);
    67.    
    68. }
    69.  
    70. void Write_EEPROM(unsigned char cmd,unsigned char addr, unsigned char *data)
    71. {
    72.     unsigned int i;
    73.     LPC_EEPROM->CMD = cmd;
    74.     LPC_EEPROM->ADDR=(addr<<6);
    75.   for(i=0;i<8;i++)
    76.   {
    77.         LPC_EEPROM->CMD = cmd;
    78.         LPC_EEPROM->WDATA  = *(data++);
    79.         while(!(LPC_EEPROM->INT_STATUS&(1<<26)));
    80.         LPC_EEPROM->INT_CLR_STATUS=(1<<26);
    81.     }
    82.  
    83.    
    84. }
    85. void PROG_EEPROM(unsigned char cmd,unsigned char addr)
    86. {
    87.     LPC_EEPROM->CMD=cmd;
    88.     LPC_EEPROM->ADDR=(addr<<6);
    89.     while(!(LPC_EEPROM->INT_STATUS&(1<<28)));
    90.     LPC_EEPROM->INT_CLR_STATUS=(1<<28);  
    91. //     EEPROM_Prog(CMD_E_P_Mem,0x00);
    92. }
    93.  
    94. unsigned char* EEPROM_Read(unsigned char cmd,unsigned char addr)
    95. {
    96.   unsigned int i;
    97.     LPC_EEPROM->CMD=cmd;
    98.     LPC_EEPROM->ADDR=(addr<<6);  
    99.     for(i=0;i<8;i++)
    100.     {
    101.       LPC_EEPROM->CMD=cmd;
    102.       r_data[i]=LPC_EEPROM->RDATA;
    103.        
    104.         while(!(LPC_EEPROM->INT_STATUS&(1<<26)));
    105.       LPC_EEPROM->INT_CLR_STATUS=(1<<26);
    106.      }
    107.     return r_data;
    108. }
    109.  
     
  4. kishore486

    Thread Starter New Member

    Mar 1, 2016
    3
    0
    Here i am using LCD-4x20 Character LCD for checking EEPROM operations
     
  5. Picbuster

    Member

    Dec 2, 2013
    374
    50
    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);
     
Loading...