Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

using EEPROM at high clock frequency

Status
Not open for further replies.

hhhsssmmm

New Member
hello

Im using a pic18f4220 with the C18 compiler.

I have successfully written and read back from EEPROM two bytes of data using 4MHz ceramic resonator.

Next I attemted to perform the same write and read operation from the EEPROM using a 10MHz ceramic resonator.
This did not work at all. My data is not being written in the address location....nor can it be read.

I then decided to use 20MHz and then all the way up to 40MHz.......and i got the same problem.
The EEPROM simply refuses to read or write anything above 4MHz clock speed.

Is this an issue with the pic18F4220?

I have used EEPROM read and write at successfully at 20MHz on a pic18f2420 and i had NO problems.

please can some one suggest how to solve this problem.

thank you

haseeb
 
I'm no PIC expert, but you may need to adjust the timing of the EEPROM-writes at a higher clock rate. Sometimes a minimum-length voltage pulse is needed, which is obtained by counting clock-pulses. If the clocks are shorter, the write pulse is shorter, maybe too short.

Wade Hassler
 
Isn't there an eeprom register/interrupt set for this so you don't have to do mess with hand coding delays?
 
If you wait for the WR bit to be clear after you write to EEPROM it should work fine.

Mike.
 
There should be a similar register flag for read.
 
Are you sure? I thought eeprom reads were timed as well? I'm probably remembering wrong. Or remembering that there's a limit to some flash micro chips not because of the clock speed or hardware but because of the limits of the flash memory.
 
There is no delay required after reading EEPROM. Some pics need a short delay (2 cycles) after reading FLASH program memory.

Mike.
 
ok here is my code below.

its a simple EEPROM write and read test program.

Im using the following...

40MHz HSPLL (10MHz ceramic resonator)
PIC18F4220
C18 compiler

the result of this program should be a simple LED flash twice which it does after a successful read from the EEPROM.

However upon verifying this result in the MPLAB PM3 programmer, when reading the EEPROM, the result comes out completely blank in the EEPROM window. The data byte 0xEA is never written in the EEPROM location 0x00.

The same happens with 10MHz or 20Mhz clock speed. HOWEVER, the same program and EEPROM verification via PM3 programmer results perfectly only when I use a 4MHz ceramic resonator.

I have also tried changing the PIC to one of serveral PIC18F4220 that I have....but all give the same results as above.

From the above test results of my program i assume (plz correct me) that when i place the PIC on to the MPLAB PM3 programmer to read the the EEPROM, then during power down the PIC loses the EEPROM content. This is strange. I have a clean 7805 stable 5V output for the PIC. Before i take the PIC out from my board, the power supply is shut off for a moment and then I take out the PIC.

Please can someone help me out that for any clock speed above 4MHz, why does the EEPROM is not able to retain its contents after the power down.

thankyou

Haseeb



Code:
#include <p18f4220.h>
#include <delays.h> 

#pragma config OSC = HSPLL
#pragma config WDT = OFF
#pragma config LVP = OFF

#define LED LATCbits.LATC3

unsigned char              
              HighByte = 0;       

void main(void)
{     

  ADCON1 = 0x0F; //SET ALL PORTS as DIGITAL I/O

  //initiallize all PORTs     
  PORTA = 0;
  PORTB = 0;  
  PORTC = 0;   
  TRISCbits.TRISC3 = 0;  //LED output
  PORTD = 0;
  PORTE = 0;

  INTCON = 0; //disable all INTs

  //byte write   
  EECON1bits.EEPGD = 0; //Ensure EEPGD is clear for EEDATA access   
  EECON1bits.WREN = 1; // //Ensure WREN is set to enable for no EEDATA writes    
  EEADR = 0x00; //Write address to EEADR at the respective location   
  EEDATA = 0xEA; //Set EEDATA to the value to write
  EECON2 = 0x55;
  EECON2 = 0xAA;           
  EECON1bits.WR = 1; //Initiate write cycle by setting the WR bit      
  while (!PIR2bits.EEIF); //Wait for the EEIF flag to be set           
  PIR2bits.EEIF = 0; //Clear the EEIF flag             
  EECON1bits.WREN = 0; // //Ensure WREN is set to dissable for no EEDATA writes

  //byte read
  EECON1bits.EEPGD = 0; //Ensure EEPGD is clear for EEDATA access                   
  EEADR = 0x00; //Store the address to EEADR               
  EECON1bits.RD = 1; //Trigger a read by setting the RD bit           
  HighByte = EEDATA;

  if(HighByte == 0xEA)    //are u the same byte read back from EEPROM?
  {                   

        //confirm correct byte read via LED flashing

        LED = 1;   
        Delay10KTCYx(250); //250ms delay    
        LED = 0;
        Delay10KTCYx(250); //250ms delay
        LED = 1;
        Delay10KTCYx(250); //250ms delay
        LED = 0;

  }

  while(1); //loopforever (STOP)

} //end of main()
 
thank you for help...

YES...you were right about the line statement "EECON1bits.CFGS = 0".

By adding this line...my EEPROM read and write routines for any clock speed work flawlessly...

thank you again:)

Haseeb
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top