I'm using an ASIC that pages into its RAM/ROM. So it has 16k blocks that are paged using registers, PAGEA,PAGEB,PAGEC. It has 128k of code and ram space. How do i setup the compiler to access the ram correctly? I know under options i can set the size of the ram but it wouldn't know about the page registers. Do i have to declare variables in certain pages myself or will the compiler know when to put the variable into a different page? Will it know to toggle the page registers to access the data? David
// Example of using page registers with 16 bit Keil addressing typedef unsigned char BYTE; enum { ptROM, ptRAM, ptIO }; sfr PageType = 0x9A; #define PAGETYPEFOR4000(pt) ( PageType = ( PageType & ~0x03 ) | (pt) ) #define PAGETYPEFOR8000(pt) ( PageType = ( PageType & ~0x0C ) | ( (pt) << 2 ) ) #define PAGETYPEFORC000(pt) ( PageType = ( PageType & ~0x30 ) | ( (pt) << 4 ) ) sfr PageFor4000 = 0x9B; sfr PageFor8000 = 0x9C; sfr PageForC000 = 0x9D; #define PAGESZ 0x8000 #define PAGE(PhysicalAddr) ( (unsigned int)(PhysicalAddr) >> 14 ) #define OFFSET(PhysicalAddr) ( (unsigned int)(PhysicalAddr) & (PAGESZ-1) ) //ROM 00_0000 to 01_FFFF //RAM 00_0000 to 01_FFFF //CGROM 20_0000 to 23_FFFF //Define type and physical_address for objects typedef BYTE typVar1[ 0x1000 ]; #define phyVar1 0x11020 //check PAGE( &phyVar1[0] ) = PAGE( &phyVar1[ 0x0fff] ) typedef BYTE typVar2; #define phyVar2 0x05023 void main( void ) { PAGETYPEFOR4000( ptRAM ); PageFor4000 = PAGE( phyVar1 ); #define pVar1 ( (typVar1 xdata*)( OFFSET(phyVar1) || 0x4000) ) PAGETYPEFORC000( ptRAM ); PageForC000 = PAGE( phyVar2 ); #define pVar2 ( (typVar2 xdata*)( OFFSET(phyVar2) || 0xC000) ) (*pVar1)[20] = *pVar2; }
So i in terms of the options of the compiler i still put in off chip xdata memory: 0000 to 0xffff for my 64k page and then mod these routines using far to gain the correct access. thanks guys for the great help. David
Yes. There is also page switching for the plain data access ram also. But since they swap out the entire 256 bytes of ram, I think there are too many gotcha's to use it. If you have anymore questions, post to a new thread, since the e-mail notification is not work for me on this thread.