LPC2388 ISP Programming

cancel
Showing results for 
Search instead for 
Did you mean: 

LPC2388 ISP Programming

109 Views
Contributor I

Hi all,

I am looking to use ISP programming. I am fairly new to it, so I would like to lay out my game plan below and see if it makes sense; otherwise, some suggestions/ideas in the right direction would be greatly appreciated.

Basically, I want to put the values of a lookup table into flash. It will be 211x11 bytes so it will come out to ~2.3 kB. I have gone through the user's manual for the processor a couple times and this is what I got from it:

  1. To start, I will bring the processor into ISP mode via an IAP command (see section 29.8.8 Reinvoke ISP).
    • I will skip Code Read Protection (CRP) since I probably won't need it (this task is a one-time deal)
    • Also, per the user manual descriptions of the commands listed in step 3 below, the commands will be blocked if CRP is enabled.
    • Unfortunately, bringing down P2.10 is not an option although it is mentioned in the manual
  2. I will send the Unlock command to unlock write, erase and go commands (see section 29.7.1 Unlock)
  3. I will send the Set Baud Rate command and set it to 19200 (see section 29.7.2 Set Baud Rate).
  4. Now for the values in the lookup table, I will issue the Write to RAMPrepare sector(s) for write operation and Copy RAM to flash commands (see sections 29.7.4, 29.7.6 and 29.7.7, respectively)
    • I am guessing that any sector that is cleared by default (0xFF's all around) is a freebie for use?
    • I can also issue a Read Memory command if needed to confirm that values are actually residing in flash
    • At the time of this writing, I am not sure how many values I can send at a time. I noticed that the ISP data should come in UU-encoded, so I still have to read up on that.
  5. Once all of that is done, I will power cycle, write some memcpy lines and (hopefully) see the same data that I put in.

Here are some other tidbits you may want to know:

  • Realterm will be used to send all ISP commands over
    • I am thinking of creating a text file with all of the write commands required, then just dumping/sending the file through Realterm.
      • This brings up another question: Do I need to account for some downtime between commands? Or will I get one of the "bad" return codes? (I have read that I need to wait for the CMD_SUCCESS return code afterwards)
  • I am using an LPC2388 processor, so it has 512 kB of on-chip non-volatile memory
    • This should be well more than enough, as long as I avoid the 8 kB boot block areas above and below, right?
  • The development kit I'm using is Keil MDK-Lite v5.22 (I also have the corresponding legacy pack installed)
  • I am guessing that if I want to load different versions of the code then I would need to do this every time I wanted the values to reside in flash.

Is there anything missing or incorrect in the game plan above? Or is it all feasible? Please let me know if I missed anything critical that I have not mentioned yet. Any other tips would help, as well.

Thank you,

Dan

(9/29) EDIT: I was able to get going with ISP programming! I do, however, have another issue with trying to copy data from RAM over to flash. I am currently trying to copy already existing data from RAM (i.e. I did not manually write said data via ISP) into flash. I noticed that some of the data gets copied fine and others are jumbled/out of place. I have a couple of things in mind to try out such as using different baud rates. Are there any other ideas for this issue? 

Other notes that may help:

  • I enabled ISP programming through the IAP command to reinvoke ISP (see above)
  • I went through the synchronization steps (12 Mhz, or 12000 kHz, was used; also see section 29.3.1.1)
  • I am making sure to prepare the sector before writing to the sector (in this case I am only interested in sector 22)

(9/30) EDIT 1: I found out that copying manually written data from RAM to flash is fine. The next issue is trying to send data from Realterm to RAM (i.e. dumping a .txt file). What I have in my .txt file does match what comes into RAM but I am certain that it has something to do with UU-encoding, as well as the fact that I'm not sending the checksum. I hope that is in the right direction! If anyone else has other tips, I am all open ears.

(9/30) EDIT 2: Problem solved! Changing the file to be UU-encoded and including the checksum worked. The only downside now is that the values are going into flash as ASCII instead of the actual values. There is an extra hassle for that conversion in the application, but all is well at this point. 

Hopefully this post can help someone else get started with ISP/IAP programming.

0 Kudos
0 Replies