Here are a few pointers to common problems that people have with returning to ROM mode from flash mode on the UCD3138 family of devices.
First a little background. The UCD family devices power up in ROM mode. The ROM reads the program flash and checks several checksums for different areas of the flash. If any of the checksums are valid, the ROM configures the Flash and jumps to the program in the flash. The only way to stay in ROM mode (for example if you want to reprogram the flash) is to have something in the flash that makes the checksum invalid. To do this, you need a program to write to the program flash and/or the flash control registers
This program cannot be executed from the program flash. This is because when the flash is written to or erased, it doesn't return valid instructions until the process is over. It will just return all Fs. In our EVM codes, we copy the checksum clearing program into RAM and execute from there. This isn't perfectly straightforward, and there are some pitfalls - here is a list of some of them:
1. The program which is copied into RAM should be compiled in its own file, and the processor mode should be set to 32 bit (ARM) mode instructions.
This is done by right clicking on the specific file name in CCS and selecting "Show Build Settings". Then select ARM Compiler->Processor Options->Designate Code State, and select 32 bits.
If you don't select this, the proper code may not be copied into the proper location. The software interrupt code used to copy from program flash to RAM starts at the ARM mode entry point. If the function is compiled in 16 bit, the 32 bit entry point will be just a 32 bit wrapper that switches to 16 bit mode, calls the 16 bit function, and then switches back to 32 bit mode and returns. The linker may not put the 32 bit wrapper anywhere near the 16 bit function. Sometimes it will, so everything will work, sometimes it won't, and things will stop working.
2. Make sure that the rest of the program is working before you program the checksum. For development work, it is generally not necessary to write the checksum. You can always use the GUI to tell the program to start running. Before setting the checksum with a new program, test the checksum clearing function. This is pretty quick:
1. download the code to the device, making sure that the checksum is not being written
2. Close the download window and return to the main window
3. Click on DEVICE ID
4. ClIck on COMMAND PROGRAM TO JUMP TO ROM
5. Click on the Checksums tab.
6. Click on Validate
7. It should return that the checksum is invalid. If it is invalid because it is all zeroes, that's good, your code is working correctly and clearing it. If it is invalid because it is all FFs, that is bad, because your code is not working correctly and not clearing the checksum
8. If the checksum is all zeroes, go ahead and click Recreate.
9. If the checksum is all FFs, try to fix your code and run the test again.
Note: This works on all EVM codes so far. The EVMS only clear the checksum - this is good for development. For a production code, it is better to erase the entire Program flash for IP security. In this case the checksum will be all FFs. But so will the rest of the flash. For this situation, for step 5, click on Command ROM to execute its program. If it finds a DEVICE ID, then the flash clear isn't working. If it doesn't find a device ID, and is back in ROM mode, you're good.