Hello, I have a memory mapping question about S12G chip.
I checked the generated prm file of MC9S12G128 project, it is as below, there are page 08 to page 0E, the map file is same as it, the .text is generated to PAGE_0E of 0xE8000. But the memory map defined in S12G reference manual is not same as it, the paging window is at 0x00000,0x04000, 0x08000, 0x30000, 0x34000, 0x38000, 0x3C000, 0x3FFFF, please see the attached doc. So it is confused how MCU access the address, like 0xE8000 in the .map file. Which memory mapping control register is used to map the location, PPAGE? But it defines only bit[17:14] of global address[17:0], 0xE8000 is a 19 bit address.
SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */
RAM = READ_WRITE 0x2000 TO 0x3FFF;
ROM_C000 = READ_ONLY 0xC000 TO 0xFEFF;
PAGE_08 = READ_ONLY 0x088000 TO 0x08BFFF;
PAGE_09 = READ_ONLY 0x098000 TO 0x09BFFF;
PAGE_0A = READ_ONLY 0x0A8000 TO 0x0ABFFF;
PAGE_0B = READ_ONLY 0x0B8000 TO 0x0BBFFF;
PAGE_0C = READ_ONLY 0x0C8000 TO 0x0C93FF;
PAGE_0C_A000 = READ_ONLY 0x0CA000 TO 0x0CBFFF;
PAGE_0E = READ_ONLY 0x0E8000 TO 0x0EBFFF;
END
the memory relationship between the .prm file and global address is as below:
S12G128 .prm | S12G128 global address copied from datasheet:
SEGMENTS |
RAM = READ_WRITE 0x2000 TO 0x3FFF; |
ROM_C000 = READ_ONLY 0xC000 TO 0xFEFF; |
PAGE_08 = READ_ONLY 0x088000 TO 0x08BFFF; | 0x20000 to 0x23FFF
PAGE_09 = READ_ONLY 0x098000 TO 0x09BFFF; | 0x24000 to 0x27FFF
PAGE_0A = READ_ONLY 0x0A8000 TO 0x0ABFFF; | 0x28000 to 0x2BFFF
PAGE_0B = READ_ONLY 0x0B8000 TO 0x0BBFFF; | 0x2C000 to 0x2FFFF
PAGE_0C = READ_ONLY 0x0C8000 TO 0x0C93FF; | 0x30000 to 0x34000
PAGE_0C_A000 = READ_ONLY 0x0CA000 TO 0x0CBFFF; |
PAGE_0E = READ_ONLY 0x0E8000 TO 0x0EBFFF; | 0x38000 to 0x3BFFF
END
Hi,
The MCU has global and local memory map (let's talk about G128).
If you do not want to write flash memory by your SW then you can forget at global memory map because it is used only when flash is written. Entire flash can be accessed by PPAGE:WindowOffest address where PPAGE is in the range 08~0F and window is in the range 8000~BFFF. (As you can see flash is not linear and routines are not allowed to exceed 16kB (size of window)). There are a part of memory which can be accessed also by local 16bit address (so called NON_BANKED memory space). It uses addresses 1400~1FFF; 4000~7FFF and C000~FFFF. Of course, these spaces can be also accessed by PPAGE:WindowOffest addressing mode.
I have attached excel sheet, we prepared, to help better understand memory mapping of S12G devices.
Moreover I have attached example code which places data to different flash areas. (prepared under CodeWarrior v.5.1)
Best Regards,
Ladislav
Hi lama
When I do not use the global address,the local address will convert to global address automatically? C000~FFFF can be accessed directly Is it physical address?
Can i think local address is logical address and global address is physical address?local address convert to global address by S12 MMC? Finally,How to work S12 MMC ?
Thank you Edward and Lama! Very clear excel.
I checked the debugger Assembly window of CW5.1, its instruction address seems logical address (page address). I also found CALL and RTC instructions are used to page memory access, like below:
C Asm
_ENABLE_COP(1) CALL 0x8000, 0x0E
main() CALL 0x806B, 0x0E
Now I'm writing a bootloader for S12G, so I need know the conversion of global address and page address, because the address in S-record is page address, yet to program flash, it is global address.
Now I'm getting clear of it. Thank you!
Regards,
dp
Hi,
thank you.
I would like to add some code examples which can help you. You will find there also converision routines from local t gloabal address.
Regarding bootloader, i would like to suggest you to read http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4258.pdf
which presents bootloader for S12G device. The source code SW files can be found at:
There is SRecCvt mentioned in the application note which converts banked S record to required form because the bootloader accepts s-records with global (linear) addressing. All records must be aligned to 32 bytes and the length of records must be 32 bytes. You can find it in the attachment with some devices adddedet to DeviceInfo.Dat file. Original version can be found at https://www.freescale.com/webapp/Download?colCode=SRECCVTSW&appType=license&location=null&Parent_nod... (it is easy to add any device to the DeviceInfo.Dat file)
Best regards,
Ladislav
Many thanks Ladislav!
I have ever read AN4258SW.pdf before, thanks for sharing the source code.
I prefer to do the logical to global address conversion in bootloader runtimely.
dp
Hi
PRM file uses paged addresses like 0x98000, where 0x9 is PPAGE setting and 0x8000 is CPU address. S12G paged address 0x98000 corresponds to global address 9*psize + (0x8000 - pstart) = 0x24000, where psize is the size of PPAGE window = 0x4000 and pstart is PPAGE window offset = 0x8000.
Global address is address used by flash controller when you specify what part of flash to erase or program.