SNIU028D February 2016 – September 2020 UCD3138 , UCD3138064 , UCD3138064A , UCD3138128 , UCD3138A , UCD3138A64
When the UCD3138 powers up, the ROM is the only memory in the entire memory space. The peripherals are also present at the extreme high end of the memory space. The ROM image is repeated throughout the rest of the memory. The reset vector at location 0 in memory is accessed by the first instruction fetch of the CPU.
This instruction is a branch to the ROM entry point, aimed at the ROM image starting at address 0xa000. This is done because eventually the ROM will be mapped to 0xa000 to 0xafff only. If the program counter is already pointing there, there is no discontinuity when the address is changed.
First in the ROM program, the three address register pairs for the other memories are changed.
Memory Fine Base Address High Registers 1-3 (MFBAHRx) are all loaded with a 1. This register provides bits 16 – 31 of the address for the device, so all of the memories will be mapped to 0x1xxxx.
The Memory Fine Base Address Low Registers 1 – 3 (MFBALRx) are loaded as follows:
Now that the other memories are mapped, the ROM is moved to fill the entire 64K space starting at zero. This is done at this point so that the ROM can still control the interrupt vectors at 0, all the other memories can be read and written, and the ROM can still execute at 0xA000.
This is done by modifying the MFBALR0 register, which controls the ROM address, and also enables the memory map.
MFBALR0 – BLOCK_SIZE = 7, RONLY = 1, MS = 1. (ADDRESS is left at 0)
This does all that is described above, as well as making it a fault if the program attempts to write to the ROM. All of the statements above are shorthand descriptions, not C code. In fact, to save space in the ROM a single constant is written to each register, with all the bit fields properly placed in it.
After the memory map is initialized in this pattern, the ROM program performs a simple additive checksum on the Program Flash. If the checksum matches, the ROM program then reconfigures the memory map and jumps to location zero in the flash.
There is also a PMBus command that can command the ROM program to do the same thing.
This reconfiguration involves two steps:
So the memory map when the Program Flash is running is:
Memory | Start | End |
---|---|---|
Program Flash | 0 | 0x7FFF |
ROM | 0xA000 | 0xAFFF |
Data flash | 0x18800 | 0x18FFF |
Program Flash | 0x19000 | 0x19FFF |
There should be no need to modify any of the memory base address registers. In fact it is highly recommended against modifying them because it is very easy to cause a fault which will cause the CPU to be reset.