Hi,
Where is your code, where is your schematic, where can we see what data you write into the EEPROM, how you verify it and what data you read from the EEPROM after power cycling?
Klaus
If i am switching of my board, at starting getting garbage value for almost 1 minute then again getting correct data.
So you are saying the data IS stored correctly but for some reason your code cant read it back for a minute after powering up?
Brian.
By this statement I have understood that you are switching off your board & not switching on. Kindly explain clearly the methods which you are following for writing the data at the location and also the method you are trying to read back at the same location during power on & Power off
It's not the problem of language. The problem is that you don't show us schematic and code.Sorry for bad english.
Yes, Understood... But not completely.. What is the interface which you used between your EEPROM & PIC? What is the EEPROM which you are using in the design?I hope now yu understood what exactly i mean.
The problem is not with your English. It is with your explanation. No issue provide the details requested to help you out.Sorry for bad english.
You know what internal EEPROM of a PIC processor is?What is the interface which you used between your EEPROM & PIC? What is the EEPROM which you are using in the design?
Share the part number.. If possible post your connection diagram.
Yes, Understood... But not completely.. What is the interface which you used between your EEPROM & PIC? What is the EEPROM which you are using in the design?
Share the part number.. If possible post your connection diagram.
The problem is not with your English. It is with your explanation. No issue provide the details requested to help you out.
... which can only mean something in your software is preventing the EEPROM read being performed, or is overwriting the result until one minute has elapsed. This has to be a coding issue so we need to see what you have done to find a solution.
Brian.
#include "xc.h"
#include "lcd_display.h"
#pragma config PLLDIV = 1 // PLL Prescaler Selection bits (No prescale (4 MHz oscillator input drives PLL directly))
#pragma config CPUDIV = OSC1_PLL2// System Clock Postscaler Selection bits ([Primary Oscillator Src: /1][96 MHz PLL Src: /2])
#pragma config USBDIV = 1 // USB Clock Selection bit (used in Full-Speed USB mode only; UCFG:FSEN = 1) (USB clock source comes directly from the primary oscillator block with no postscale)
// CONFIG1H
#pragma config FOSC = INTOSC_HS//XT_XT//XT_XT // Oscillator Selection bits (XT oscillator (XT))
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
#pragma config IESO = OFF // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)
// CONFIG2L
#pragma config PWRT = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOR = ON // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled))
#pragma config BORV = 3 // Brown-out Reset Voltage bits (Minimum setting)
#pragma config VREGEN = OFF // USB Voltage Regulator Enable bit (USB voltage regulator disabled)
// CONFIG2H
#pragma config WDT = OFF//ON // Watchdog Timer Enable bit (WDT enabled)
#pragma config WDTPS = 32768 // Watchdog Timer Postscale Select bits (1:32768)
// CONFIG3H
#pragma config CCP2MX = ON // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
#pragma config PBADEN = ON // PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset)
#pragma config LPT1OSC = OFF // Low-Power Timer 1 Oscillator Enable bit (Timer1 configured for higher power operation)
#pragma config MCLRE = ON // MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)
// CONFIG4L
#pragma config STVREN = ON // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
#pragma config LVP = OFF//ON // Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)
#pragma config ICPRT = OFF // Dedicated In-Circuit Debug/Programming Port (ICPORT) Enable bit (ICPORT disabled)
#pragma config XINST = OFF // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))
// CONFIG5L
#pragma config CP0 = OFF // Code Protection bit (Block 0 (000800-001FFFh) is not code-protected)
#pragma config CP1 = OFF // Code Protection bit (Block 1 (002000-003FFFh) is not code-protected)
#pragma config CP2 = OFF // Code Protection bit (Block 2 (004000-005FFFh) is not code-protected)
#pragma config CP3 = OFF // Code Protection bit (Block 3 (006000-007FFFh) is not code-protected)
// CONFIG5H
#pragma config CPB = OFF // Boot Block Code Protection bit (Boot block (000000-0007FFh) is not code-protected)
#pragma config CPD = OFF // Data EEPROM Code Protection bit (Data EEPROM is not code-protected)
// CONFIG6L
#pragma config WRT0 = OFF // Write Protection bit (Block 0 (000800-001FFFh) is not write-protected)
#pragma config WRT1 = OFF // Write Protection bit (Block 1 (002000-003FFFh) is not write-protected)
#pragma config WRT2 = OFF // Write Protection bit (Block 2 (004000-005FFFh) is not write-protected)
#pragma config WRT3 = OFF // Write Protection bit (Block 3 (006000-007FFFh) is not write-protected)
// CONFIG6H
#pragma config WRTC = OFF // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) are not write-protected)
#pragma config WRTB = OFF // Boot Block Write Protection bit (Boot block (000000-0007FFh) is not write-protected)
#pragma config WRTD = OFF // Data EEPROM Write Protection bit (Data EEPROM is not write-protected)
// CONFIG7L
#pragma config EBTR0 = OFF // Table Read Protection bit (Block 0 (000800-001FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR1 = OFF // Table Read Protection bit (Block 1 (002000-003FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR2 = OFF // Table Read Protection bit (Block 2 (004000-005FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR3 = OFF // Table Read Protection bit (Block 3 (006000-007FFFh) is not protected from table reads executed in other blocks)
// CONFIG7H
#pragma config EBTRB = OFF // Boot Block Table Read Protection bit (Boot block (000000-0007FFh) is not protected from table reads executed in other blocks)
#define _XTAL_FREQ 20e6
unsigned char d0,d1;
unsigned char e_address;
unsigned char e_data;
void main()
{
ADCON1 = 0x0F;
TRISD = 0;
lcd_display_on();
EECON1bits.CFGS = 0;
EEPROM_Write(0xF0, 0x30);
d0 = EEPROM_Read(0xF0);
lcd_data(d0);
EEPROM_Write(0xF1, 0x31);
d1 = EEPROM_Read(0xF1);
lcd_data(d1);
while(1)
{}
}
void EEPROM_Write(unsigned char e_address, unsigned char e_data)
{
EEADR = e_address;
EEDATA = e_data;
EECON1bits.EEPGD = 0;
EECON1bits.WREN = 1;
INTCONbits.GIE = 0;
EECON2 = 0xAA;
EECON1bits.WR = 1;
INTCONbits.GIE = 1;
EECON1bits.WREN = 0;
while(PIR2bits.EEIF == 0)
{
}
PIR2bits.EEIF = 0;
}
unsigned char EEPROM_Read(unsigned char e_address)
{
EEADR = e_address;
EEDATA = e_data;
EECON1bits.EEPGD = 0;
EECON1bits.WREN = 0;
EECON1bits.CFGS = 0;
EECON1bits.RD = 1;
return(EEDATA);
}
I am using Internal EEPROM.
The write to EEPROM unlock sequence is wrong, it shouldn't be writing anything to EEPROM at all.
You MUST use the exact sequence of writing 0x55 to EECON2 then writing 0xAA to EECON2. You are missing out the 0x55 part.
Brian.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?