Eeprom not able to write

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Eeprom not able to write

913 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by aamir ali on Tue Nov 20 02:39:03 MST 2012
Hi I am not able to write eeprom, what error I am doin here:LPC1317-64pin. Running CPU core at 72Mhz.
Is there anyu enable bit also like in for other peripherals in SYSAHBCLKCTRL.
Also any register to set 375Khz-typical freq for eeprom or just write in command[4] = 375; value.


    uint8_t x=100;
    uint8_t y= 100;
    uint8_t z=0;
    writeEEPROM( (uint8_t*) x, (uint8_t*)&y, 1 );
    
    readEEPROM( (uint8_t*) x,(uint8_t*) &z, 1 );




#define IAP_LOCATION 0x1FFF1FF1
typedef void (*IAP) (unsigned int command[],
unsigned int result[] );
static const IAP iap_entry = (IAP) IAP_LOCATION;
//1) EEprom Write
//
//Command code: 61
//Param0: eeprom address (byte, half-word or word aligned)
//Param1: RAM address (byte, half-word or word aligned)
//Param2: Number of bytes to be written ( Byte, Half-words write are ok)
//Param3: System Clock Frequency (CCLK) in kHz
//
//Return Code CMD_SUCCESS | SRC_ADDR_NOT_MAPPED | DST_ADDR_NOT_MAPPED 
void writeEEPROM( uint8_t* eeAddress, uint8_t* buffAddress, uint32_t byteCount )
{
unsigned int command[5], result[4];

command[0] = 61;                  
command[1] = (uint32_t) eeAddress;
command[2] = (uint32_t) buffAddress;
command[3] = byteCount;            
command[4] = 375;

/* Invoke IAP call...*/
iap_entry(command, result);
if (0 != result[0])
{
//Trap error
while(1);
}
return;
}

//2) EEprom Read
//Command code: 62
//Param0: eeprom address (byte, half-word or word aligned)
//Param1: RAM address (byte, half-word or word aligned)
//Param2: Number of bytes to be read ( Byte, Half-words read are ok)
//Param3: System Clock Frequency (CCLK) in kHz
//
//Return Code CMD_SUCCESS | SRC_ADDR_NOT_MAPPED | DST_ADDR_NOT_MAPPED
void readEEPROM( uint8_t* eeAddress, uint8_t* buffAddress, uint32_t byteCount )
{
unsigned int command[5], result[4];

command[0] = 62;                  
command[1] = (uint32_t) eeAddress;
command[2] = (uint32_t) buffAddress;
command[3] = byteCount;            
command[4] = 375;

/* Invoke IAP call...*/
  iap_entry( command, result);
if (0 != result[0])
{
//Trap error
while(1);
}
return;
}
0 项奖励
回复
3 回复数

856 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tha on Mon Nov 26 12:56:47 MST 2012
The clock frequency for the EEPROM should be in the System Clock Frequency in kHz not an absolute value.  If you are using the CMSIS file, you can first get the System Clock by making a call to:
SystemCoreClockUpdate();

Then in the read/write function, for command[4], you can do this:
command[4] = SystemCoreClock/1000
0 项奖励
回复

856 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by aamir ali on Fri Nov 23 02:51:28 MST 2012
help abt dis.......
0 项奖励
回复

856 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by aamir ali on Tue Nov 20 03:43:35 MST 2012
Hi,

Found the problem, SYSAHBCLKDIV was not initialized properly.

question:

1. Like EEprom speed is 375Khz typical. But system runs at 72Mhz. So have to switch b/w two.
Now when changing SYSAHBCLKDIV_Val b/w 192 for 375Khz & set value to 1 for 72Mhz.
How do get indication that clock now gets stable after changing SYSAhbclkdiv.
like:
CLKDIV = 192;     // switch for eeprom programming.

/.........Should I wait here for some time for clock gets stable or no need or any flag for it.


2. eeAddress varies from 0-4031 or 64-4095
0 项奖励
回复