XE167H FLASH programming sequence error!

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
I'm using XE167H chip, and I'm testing flash programming function.
The environment is as below:
(1) Main program use Internal Flash Start from 0xC00000, code length less than 0xEFFF;
(2) The program try to remove and write data into 0xC10000 to 0xCFFFFF;
(3) I found that pages in 0xCxxx00 to 0xCxxx7F can be removed and written into, but pages from 0xCxxx80 to 0xCxxxFF can not be removed and written into, and will report sequence error;
(4) changing to 0xC40000 - 0xCFFFFF leads to the same result;

How to solve this problem, or any mistake?
Thank you!

Quakel

/////////////////////////////////////////////////////////
// Function to erase one page of the flash.
// * Parameter: adr: page Address
// * Return Value: 0 - OK, 1 - Failed
////////////////////////////////////////////////////////
uword Flash_erase_page (ulong ulPage_Addr)
{
(*((uword far *) (base |0xAA))) = 0x80; // Erase Sector (1. Cycle)
(*((uword far *) (base |0x54))) = 0xAA; // Erase Sector (2. Cycle)
(*((uword far *) (ulPage_Addr))) = 0x03; // Erase Sector (3. Cycle)
return (Flash_Check()); // Check until Device Ready
}

////////////////////////////////////////////////////////
// Function to Program one flash data page.
// * Parameter: adr: Block Address
// * buf: Block Data
// * Return Value: 0 - OK, 1 - Failed
////////////////////////////////////////////////////////
uword Flash_ProgramPage (ulong page_adr, void *buf)
{
uword cnt, uwTmp;
// Enter Page Mode
(*((uword far *) (base |0x00AA))) = 0x50; // 1st cycle: write 50h to xx'00AAh
(*((uword far *) (page_adr))) = 0xAA; // 2nd cycle: write AAh to page start address
uwTmp = (Flash_Check()); // Check until Device Ready

if (uwTmp == 0)
{
// Load Page
for (cnt=0; cnt<64; cnt++)
{
(*((uword far *) (base |0x00F2))) = (*(uword *)buf); // write word from R4 to xx'00F2h
buf = (uword *) buf+1;
}
// Write Page
(*((uword far *) (base |0x00AA))) = 0xA0; // 1st cycle: write A0h to xx'00AAh
(*((uword far *) (base |0x5A))) = 0xAA; // 2nd cycle: : write AAh to xx'005A
uwTmp = Flash_Check(); // Check until Device Ready
}
return (uwTmp);
}
0 Likes
1 Reply
Not applicable
This stupid error example is taken from AppNote 16164:
/**************************************************************************
** *
** INFINEON XC20007XE16x AP16164 , CAN_loader, Version 1.0 *
** *
** Id: FlashDev.c 2009-10-1 YS

All the commands in AppNote 16164 is using the form "base | 0xAA" which can work on when address are xxxx00, it shall be modified to "( base & 0xFFFFFF00 ) | 0xAA".

This error took me a whole day to solve, so don't take it for granted that AppNote examples are all correct!!!
0 Likes