# Banked and non banked memory

I have this question of banked and non banked memory specifically for freescale s12x controllers. They have both banked and non banked ram and flash memory. I know it will start putting first data in non banked ram, now suppose I exceed the limit will it automatically start putting in banked ram? If I have to take care then I feel I will loose the advantage of banked memory. Similarly for flash memory.

In the 68HC12A4, for example, there are two areas are available for data banking, the first from 0x7000 to 0x7fff (4KB) using the DPAGE register, and 0x0000 to 0x03ff or 0x0400 to 0x07ff (1K) using the EPAGE register. Apparently the two EPAGE areas overlap (bit 10 of the address is a don't care).

With the Cosmic C Cross Compiler for the HC12/HCS12, a variable in the DPAGE area can be specified using the @far modifier on the declaration. A variable in the EPAGE area can be specified using @epage and @far. For example,

@far int i;          // DPAGE area
@epage @far int j;   // EPAGE area


I don't think the compiler automatically starts using banked RAM after filling up non-banked RAM, you must use these keywords.

A variable can be located in the code bank using @far with the const keyword:

@far const int k;        // PPAGE area


Such a variable can only be accessed in a function located in a non-banked area.

Similarly, functions are located in a banked area using the @far keyword.

@far int func(void)
{
...
}


The syntax for other compilers (such as CodeWarrior) may vary, but they would have to use a similar mechanism. Check your compiler manual.