Hi Ferenc,
Unfortunately, there isn’t way how to exactly detect differences between some of the derivatives directly from a code.
S12G:
You cannot distinguish between 16kB and 32kB, between 48kB and 64kB, between 96kB and 128kB, between 192 and 240kB derivatives.
S12VR:
You cannot distinguish between 16kB and 32kB, between 48kB and 64kB derivatives.
In fact, the chips are the same, just some part of Flash is not fully tested. However, your bootloader may erase even that page.
The simplest way how to detect a flash size is reading Part ID. The S12G/S12VR doesn’t have special register with a flash size information.
The example of such routine may be found in AN4258. Updated version for you:
static UINT8 EraseFlash(void)
{
switch (PARTID)
{
//S12G
case MASK_0N95B:
//erase whole P-Flash memory except bootloader area
return(PFlash_EraseSectorBySector(0x004000UL, 0x03EFDFUL));
case MASK_0N51A:
//erase whole P-Flash memory except bootloader area
return(PFlash_EraseSectorBySector(0x020000UL, 0x03EFDFUL));
case MASK_0N75C:
case MASK_1N75C:
//erase whole P-Flash memory except bootloader area
return(PFlash_EraseSectorBySector(0x030000UL, 0x03EFDFUL));
case MASK_0N48A:
case MASK_1N48A:
//erase whole P-Flash memory except bootloader area
return(PFlash_EraseSectorBySector(0x038000UL, 0x03EFDFUL));
//S12VR
case MASK_0N59H:
case MASK_0N05E:
case MASK_1N05E:
case MASK_2N05E:
case MASK_0N92B:
//erase whole P-Flash memory except bootloader area
return(PFlash_EraseSectorBySector(0x030000UL, 0x03EFDFUL));
case MASK_0N11N:
//erase whole P-Flash memory except bootloader area
return(PFlash_EraseSectorBySector(0x038000UL, 0x03EFDFUL));
default:
return(UnknownPartID);
}
}
Note: the 0N92B, 0N05E, 1N05E and 2N05E masksets are obsolete versions of S12VR.
PartIDs:
0N92B 0x3280
0N05E 0x3281
1N05E 0x3281
2N05E 0x3282
0N59H 0x3290
0N11N 0x3380
0N95B 0xF080
0N51A 0xF180
0N75C 0xF280
1N75C 0xF281
0N48A 0xF380
1N48A 0xF381
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------