IAP write block not blank

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IAP write block not blank

4,415 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by blasiis on Wed Apr 20 08:56:29 MST 2011
I'm using LPC1758 with LPCXpresso
I have try to use the IAP command "copy ram to flash" when the sector flash it isn't blank, but i need only to move a bit from 1 to 0.
Using this function other bit is write to 0 !!!
Why ? I cannot write a 256 byte block already write ?

Thanks
0 Kudos
Reply
30 Replies

3,824 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by blasiis on Thu Apr 28 02:38:03 MST 2011

Quote: larryvc
I'm glad you got an answer to your original problem.:)

Did you ever get the fast console print to work for you?  That is what I thought you were still having a problem with.:confused:

The next release of LPCXpresso has an improved method for printing to the console and these workarounds won't be necessary.

stai bene,
Larry



I have never used the console print, will try it in the next version as: 3.7 ?
0 Kudos
Reply

3,824 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Wed Apr 27 10:49:04 MST 2011

Quote: blasiis
This is the correct answer of my problem recived from official NXP email:



I'm glad you got an answer to your original problem.:)

Did you ever get the fast console print to work for you?  That is what I thought you were still having a problem with.:confused:

The next release of LPCXpresso has an improved method for printing to the console and these workarounds won't be necessary.

stai bene,
Larry
0 Kudos
Reply

3,824 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by blasiis on Wed Apr 27 05:30:23 MST 2011
This is the correct answer of my problem recived from official NXP email:


[COLOR=black][SIZE=3][FONT=Times New Roman]The  flash consists of sectors of 4 kbytes with pages of 256 byte . Each page  consists of flash words of 16 bytes.[/FONT][/SIZE][/COLOR]
[COLOR=black][SIZE=3][FONT=Times New Roman]So a  pages consists 16 flash words. A flash word has an error correction mechanism  that will be written to when you program a Flash word. A second write/program to  that flash word after an erase (of a sector) is not possible because you can not  write the correct additional error correction bits of that flash  word.[/FONT][/SIZE][/COLOR]
 
[COLOR=black][SIZE=3][FONT=Times New Roman]After  erasing you can only write once to a Flash word. You can however write 0xFF to  the flash word for the second time. So a page can be written to 16 times . First  the first flash word with the data and the others with 0xFF. Then the second  flash word with data and the first and the third till sixteenth flash word with  0xff etc.[/FONT][/SIZE][/COLOR]
[COLOR=black][SIZE=3][FONT=Times New Roman]After  sixteen times you can not use the page anymore and you have to start with the  second page.[/FONT][/SIZE][/COLOR]
[COLOR=black][SIZE=3][FONT=Times New Roman]After  erasing the sector (4 kbytes) you can program again the first page  .[/FONT][/SIZE][/COLOR]
[COLOR=black][/COLOR]
 
[COLOR=black][/COLOR]
[COLOR=black][SIZE=3][FONT=Times New Roman]So You  has to take care of in his program that he writes only once to a flashword with  data. Wri[/FONT][/SIZE][/COLOR]
0 Kudos
Reply

3,823 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by blasiis on Wed Apr 27 04:31:19 MST 2011

Quote: larryvc
What is correct?

Which problem remains?  The original problem or the cr_fast_printf problem?



This remain !
Viewed with lpcxpresso vindow memory but also with array in code:
The 26 sector is blank (all bye a FF)
Write 0x00060000 = 00 - no problem
Write 0x00060001 = 00 - no problem
Write 0x00060002 = 00 - also the address 0x0006000B = BF !!!!!
0 Kudos
Reply

3,824 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Wed Apr 27 00:49:27 MST 2011

Quote: blasiis
This is correct, but the problem remain !



What is correct?

Which problem remains?  The original problem or the cr_fast_printf problem?


You will find "cr_fast_printf" code in the "RDB1768cmsis_efsl_demo" example in LPCXpresso.  Look at this example to better understand how this works.

Do not use the library version from my last post.

Follow the instructions I gave you here:

http://knowledgebase.nxp.com/showpost.php?p=6761&postcount=3
0 Kudos
Reply

3,824 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by blasiis on Tue Apr 26 23:59:18 MST 2011

Quote: larryvc
See this post on using a library of consoleprint and cr_fast_printf combined.

http://knowledgebase.nxp.com/showthread.php?p=7727#post7727

@TheFallGuy,  Thanks for the vote of confidence. Larry



This is correct, but the problem remain !
0 Kudos
Reply

3,824 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Fri Apr 22 10:45:03 MST 2011
See this post on using a library of consoleprint and cr_fast_printf combined.

http://knowledgebase.nxp.com/showthread.php?p=7727#post7727

@TheFallGuy,  Thanks for the vote of confidence. Larry
0 Kudos
Reply

3,824 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Fri Apr 22 07:32:12 MST 2011
If you follow *ALL* the instructions, it will work.
0 Kudos
Reply

3,824 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by blasiis on Fri Apr 22 06:02:24 MST 2011

Quote: TheFallGuy
What larryvc described works with both Red Probe and LPC-Link


I have error, don't know  cr_fast_printf
0 Kudos
Reply

3,824 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Fri Apr 22 03:08:31 MST 2011
What larryvc described works with both Red Probe and LPC-Link
0 Kudos
Reply

3,824 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by blasiis on Fri Apr 22 02:22:58 MST 2011

Quote: larryvc
Why don't you try using a printf in semihosting mode to read and display the values in sector 26?  This way you will be able to determine if the debugger is returning correct values from your hardware or not.

It will be slow, but there are ways to speed up the output to the console.  See this post:

http://knowledgebase.nxp.com/showpost.php?p=6761&postcount=3



I don't have red proble but only lpclink.
0 Kudos
Reply

3,826 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Fri Apr 22 01:11:30 MST 2011
Why don't you try using a printf in semihosting mode to read and display the values in sector 26?  This way you will be able to determine if the debugger is returning correct values from your hardware or not.

It will be slow, but there are ways to speed up the output to the console.  See this post:

http://knowledgebase.nxp.com/showpost.php?p=6761&postcount=3
0 Kudos
Reply

3,826 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by blasiis on Fri Apr 22 00:35:21 MST 2011

Quote: larryvc
blasiis,

Bestia maiale.:D

I see you have

tmp = flash_buf[pnt] <<1;       // force to 0 the last bit at level 1
flash_buf[pnt] = tmp;

What is "pnt" defined as and what is it set to?

If you want,  export your code and attach it here.  I can try it on an LPC1769.



I have change the code now for make test.
Try this wuth lpcxpresso:
1) Mass Erase
2) Load application with write flash in a loop (1 second) like this:

uint8_t flash_buf[FLASH_BUF_SIZE];
addSett = 0x00060000;
 add = addSett ;
 
// main every 1 second for example 
     // read 256 block 
     for (i = 0; i <FLASH_BUF_SIZE; i++)
       {
       flash_buf = (*(uint8_t *)add);
       add ++;
       }

IAP_WriteFlash(26, 26, (unsigned)addSett, (unsigned *)flash_buf, FLASH_BUF_SIZE);   <--- break
// end main


void IAP_WriteFlash(unsigned Start, unsigned End, unsigned flash_address, unsigned * flash_data_buf, unsigned count)
{
    IAP_SectorPrepare(Start, End, SystemCoreClock/1000);
        IAP_WriteData(SystemCoreClock/1000, flash_address, flash_data_buf, count);


void IAP_SectorPrepare(unsigned start_sector,unsigned end_sector,unsigned cclk)
{
    __disable_irq();
      param_table[0] = PREPARE_SECTOR_FOR_WRITE;
      param_table[1] = start_sector;
      param_table[2] = end_sector;
      param_table[3] = cclk;
      iap_entry(param_table,result_table);
    __enable_irq();
}

void IAP_WriteData(unsigned cclk, unsigned flash_address, unsigned * flash_data_buf, unsigned count)
{
    __disable_irq();
      param_table[0] = COPY_RAM_TO_FLASH;
      param_table[1] = flash_address;
      param_table[2] = (unsigned)flash_data_buf;
      param_table[3] = count;
      param_table[4] = cclk;
      iap_entry(param_table,result_table);
    __enable_irq();
}

3) Add break at IAP_WriteFlash call (not run for too many write)
4) Run
5) When break change in  flash_data_buf [0] = 0;
6 ) Run
7) When break check in debug window mwmory address 0x00060000 = 0
8 ) change in  flash_data_buf [1] = 0; ([0] already = 0)
9) Run
10) When break check in debug window mwmory address 0x00060001 = 0
11) change in  flash_data_buf [2] = 0; ([0 and 1] already = 0)
12) Run
13) When break check in debug window mwmory address 0x00060002 = 0 and 0x0006000B = BF !!!!!!!!!! ????????????
0 Kudos
Reply

3,826 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Fri Apr 22 00:07:40 MST 2011
blasiis,

Bestia maiale.:D

I see you have

tmp = flash_buf[pnt] <<1;       // force to 0 the last bit at level 1
flash_buf[pnt] = tmp;

What is "pnt" defined as and what is it set to?

If you want,  export your code and attach it here.  I can try it on an LPC1769.
0 Kudos
Reply

3,826 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by blasiis on Thu Apr 21 23:47:12 MST 2011

Quote: larryvc
This sounds like a hardware problem, bad flash.

Do you have another chip to test?


You had a Good idea :D !!
But unfortunately after I tried the same result . . . . :(

Viewed with lpcxpresso vindow memory but also with array in code:
The 26 sector is blank (all bye a FF)
Write 0x00060000 = 00 - no problem
Write 0x00060001 = 00 - no problem
Write 0x00060002 = 00 - also the address 0x0006000B = BF !!!!!

Remember that when write, befor i not erase the sector, but i move the bit only to 0 !!!!!
0 Kudos
Reply

3,826 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Thu Apr 21 10:19:02 MST 2011

Quote: blasiis

Here comes my problem: When write a byte from FF to FE in a 256 block where other byte it isn't  a FF some bit goes wrongly to zero in the same block !!



This sounds like a hardware problem, bad flash.

Do you have another chip to test?
0 Kudos
Reply

3,826 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by blasiis on Thu Apr 21 09:19:20 MST 2011

Quote: rmteo
Several companies (such as Microchip and ST) have published app notes describing how to use FLASH memory as EEPROM.  Using these software techniques you can achieve [B][U]effective[/U] [/B]FLASH endurance equivalent to EEPROM up to several million write cycles.  I have used the MCHP AN1095 app note - code is in C and should be easily adaptable.



I cannot change Microprocessor !
I know the techniques for use flash as eeprom (2 bank in alternation).
But this case is different: I need to write many time (15 min ) a timer value decremented, for solve the endurance flash cycle (10.000), I have think to start from a 4k sector with all bit in at 1 (flash erased) and any 15 minutes erase a single bit in byte in sequence.
Here comes my problem: When write a byte from FF to FE in a 256 block where other byte it isn't  a FF some bit goes wrongly to zero in the same block !!
0 Kudos
Reply

3,826 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rmteo on Thu Apr 21 08:39:49 MST 2011
Several companies (such as Microchip and ST) have published app notes describing how to use FLASH memory as EEPROM.  Using these software techniques you can achieve [B][U]effective[/U] [/B]FLASH endurance equivalent to EEPROM up to several million write cycles.  I have used the MCHP AN1095 app note - code is in C and should be easily adaptable.

______________________________________
Why use 8 bits when you can have 32?
ARM CORTEX Rules!!! :D:D:D
0 Kudos
Reply

3,826 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Apr 21 08:23:02 MST 2011

Quote: TheFallGuy
Have you looked at the LPC1777x and LPC178x families? They have a 4K EEPROM.



Sounds lika a good idea, but

1. Product status: Development :mad:

2. Package: >= LQFP144 :mad::mad:
0 Kudos
Reply

3,826 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Thu Apr 21 08:00:55 MST 2011
Have you looked at the LPC1777x and LPC178x families? They have a 4K EEPROM.
0 Kudos
Reply