R
risha
#pragma CODE_SEG NON_BANKED
unsigned char read8bSRAMlinear(unsigned long addr)
{
static unsigned char storedPage;
static unsigned char calcPage;
static unsigned int offset;
static unsigned char data;
calcPage = (unsigned char) (addr / 0x4000); // 0x4000 = page
size
offset = ((addr % 0x4000) + 0x8000);
storedPage = PPAGE;
PPAGE = calcPage;
data = *((unsigned char *)(offset));
PPAGE = storedPage;
return data;
}
void write8bSRAMlinear(unsigned long addr,unsigned char data)
{
static unsigned char storedPage;
static unsigned char calcPage;
static unsigned int offset;
calcPage = (unsigned char) (addr / 0x4000); // 0x4000 = page
size
offset = ((addr % 0x4000) + 0x8000);
storedPage = PPAGE;
PPAGE = calcPage;
*((unsigned char *)(offset)) = data;
PPAGE = storedPage;
}
//------------------------------------------------------------------------------
#pragma CODE_SEG DEFAULT // place to default paged memory
void writemain(void)
{
unsigned long address;
unsigned char data;
//--- NORMAL EXPANDED WIDE ---------------
//PEAR = PEAR_RDWE_MASK | PEAR_LSTRE_MASK; // enable R/W & LSTRB
signal on port E (see S12MEBIV3.pdf)
//MODE |= (MODE_MODA_MASK+MODE_MODB_MASK+MODE_EMK_MASK); //
switch to Expanded Narrow mode emulate port K
//DDRS = 0xFF; // output port
//DDRM = 0xFF; // output port
data = 0;
for(;
{
// linear writting to external memory
for(address=0;address<MAX_ADDRESS;address++)
{
write8bSRAMlinear(address, data); // write data to
external RAM
}
// linear reading from external memory
for(address=0;address<MAX_ADDRESS;address++)
{
PTM = read8bSRAMlinear(address); // read data from
external RAM and put them to the port M
}
}
}
//------------------------------------------------------------------------------
can someone explain the working of this #pragma whther it substitutes
or is like a function how does it work?
Using metrowerkscode warrior
Risha
unsigned char read8bSRAMlinear(unsigned long addr)
{
static unsigned char storedPage;
static unsigned char calcPage;
static unsigned int offset;
static unsigned char data;
calcPage = (unsigned char) (addr / 0x4000); // 0x4000 = page
size
offset = ((addr % 0x4000) + 0x8000);
storedPage = PPAGE;
PPAGE = calcPage;
data = *((unsigned char *)(offset));
PPAGE = storedPage;
return data;
}
void write8bSRAMlinear(unsigned long addr,unsigned char data)
{
static unsigned char storedPage;
static unsigned char calcPage;
static unsigned int offset;
calcPage = (unsigned char) (addr / 0x4000); // 0x4000 = page
size
offset = ((addr % 0x4000) + 0x8000);
storedPage = PPAGE;
PPAGE = calcPage;
*((unsigned char *)(offset)) = data;
PPAGE = storedPage;
}
//------------------------------------------------------------------------------
#pragma CODE_SEG DEFAULT // place to default paged memory
void writemain(void)
{
unsigned long address;
unsigned char data;
//--- NORMAL EXPANDED WIDE ---------------
//PEAR = PEAR_RDWE_MASK | PEAR_LSTRE_MASK; // enable R/W & LSTRB
signal on port E (see S12MEBIV3.pdf)
//MODE |= (MODE_MODA_MASK+MODE_MODB_MASK+MODE_EMK_MASK); //
switch to Expanded Narrow mode emulate port K
//DDRS = 0xFF; // output port
//DDRM = 0xFF; // output port
data = 0;
for(;
{
// linear writting to external memory
for(address=0;address<MAX_ADDRESS;address++)
{
write8bSRAMlinear(address, data); // write data to
external RAM
}
// linear reading from external memory
for(address=0;address<MAX_ADDRESS;address++)
{
PTM = read8bSRAMlinear(address); // read data from
external RAM and put them to the port M
}
}
}
//------------------------------------------------------------------------------
can someone explain the working of this #pragma whther it substitutes
or is like a function how does it work?
Using metrowerkscode warrior
Risha