This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

In Application Programming for LPC2368

Dear All;

I am working for an automotive project using LPC2368. Here, I want to write datas from CAN network to the 512KB Flash of LPC2368 while application is running . The data, we want to store is some critical data from CAN network.As per IAP standard we have to reduce the CPU clock while Programming the FLASH. If we are reducing the clock while CAN is working ,this is affecting CAN reception.As a solution ,if we getting the data from the CAN network ,first we are writing these data to 2KB of Battery RAM and then writing from battery RAM to FLASH while bigining of next booting time.Here for every booting time ,first of all read data from FLASH and attach data from battery RAM and then write whole data again to same FLASH.Now Flash contain a sequence of DATA from battery RAM . This methode is working fine for ISP programming.But if I am using JTAG ,all the previous data get erased
from Flash.hence I will be having only last data from Battery RAM. Will you please tell me that ,what is the difference in downloading the hex file using JTAG and ISP .How old data from flash get erased , when we ae using JTAG.

sincerely shamsudheen OP

Parents Reply Children
  • Yes, FlashMagic also have a setting to do a full erase, or to only erase the used sectors

  • No, FlashMagic is one way of programming the chip but the OP specifically wrote "But if I am using JTAG ,all the previous data get erased"

    If debugging using the JTAG interface, it is most definitely a workaround to switch to FlashMagic and download a new application - especially if the hardware doesn't allow easy access to reset and EINT0 to enter the built-in boot loader.

  • Dear sir, sorry,I don't want to erase sectors.my programming flow is shown below,

     main()
       {
     read_old_data_from_flash_to_user_Buffer(); //I am putting a count in the first byte of buffer ,such that
    I can read available data  using this count.
    
          copy_data_from_Battery_RAM_and_attach_to_User_Buffer_;//battery Ram also contain a count ,such taht I can read available data
    
    write_attached_data_to_flash;
    
    
    if(USB_is_connected)
      {
      write_USB_data_to_flash;//address 0x70000
      }
    
    
    
    while(1)
        {
         receive_data_from_CAN()
    
         write_x_data_to_battery_RAM()  //here we are writing to battery RAM because,programming Battery RAM is faster than programming FLASH memory and after every data I am incrementing the count in the first byte.
        }
    
    return 0;
    }
    
    
    

    There are two types of datas in Flash;
    1>Data from USB is written to one sector (address - 0x70000)

    2>Data from Battery RAM keep on attaching to FLASH(address 0x58000) after every booting time,if the data is there in Battary RAM.

    Data in Flash(0x70000) is retaining eventhoug I am using JTAG for Downloading.Hence that is fine. But data in Flash(0x58000) get erased ,if I am using JTAG for downloading.But if I am using ISP all old data will be there in the FLASH(Thats, we want).

    will you please tell me that, why the data from FLASH get erased if I am using JTAG for downloading or debugging.

    I noticed one thing that,ISP resetting the controller two times per downloading the hex file(with a time gap in between them).

    But JTAG resettig Controller three times per downloading(There is no much time gap in between them).

    Hence I tested one thing that,If I am resetting the controller manullay two times continously(no time gap in between them (just like JTAG),that time also , old data from FLASH get erased.

    Sincerely
    shamsudheen OP

  • When upgrading the application using the JTAG interface, you most definitely want to erase flash sectors. Just not all sectors.

    Have you tried my two suggestions?

    By the way, resetting the chip should not affect the retention of the flash sectors. Are you sure that it isn't your own IAP code that destroys your data sectors if you reset the chip several times quickly? For example because your IAP code is busy to save data from the battery-backed RAM when you reset the controller a second time?

  • dear sir;

    sorry for mentioning that ,me allready checked the two suggestion.
    1>In the setting ,it is in "Erase Sectors" . this will not make any problem,because ,some data allready there in some sector of FLASH,which is not erased even after downloading.

    2>I used sectors of sizes 4K (0x7B000),32k (0x58000)still the problem exists.

    "Are you sure that it isn't your own IAP code that destroys your data "

    this I do no,Will u please tell me,how to monitor the same.

  • "2>I used sectors of sizes 4K (0x7B000),32k (0x58000)still the problem exists."

    I'm not sure I follow your logic. I wasn't asking for how much of the flash you use for your data storage. I wondered if you have tried to change the project settings, and specifying a smaller flash. The LPC2368 has 512kB flash. What happens if you say that your chip only has 256kB flash - i.e. the same amount as the LPC2366?

    Whenever your application boots, you have written that you copy data from the battery-backed RAM to flash. During that copy procedure (until the IAP is ongoing) you must not reset the chip, or you will not know in what state the IAP is. If this works or not depends on how the programming algorithm requests erase of the chip. If the request is to erase everything, then it doesn't matter what size the project says the flash is. If the request is to erase a memory range, then decreasing the flash size in the project will decrease the number of sectors that will be erased.

    Have you tried to write a flag to the battery-backed RAM when you start the IAP and clearing the flag when the IAP is done? If your program boots and finds that this flag is already set, then you know that the previous IAP attempt got interrupted. Then you also know that your code performs the IAP within a time span where it is sensitive to the multiple resets caused by the programming, and all bets are off about the retention of data in your IAP-programmed flash area.