Hello,
How to use "unsigned long" in external RAM array?
here is the example code:
#pragma ADDRESS ext_mem 200000H // External RAM start address
far unsigned long ext_mem;
void main (void) {
ext_mem = 0x12345678;
}
After check address 200000H i saw strange results in adrress 200000H has correct results(1234H), but in address 200001H the results is diferent than 5678H.
External ram is 16 bit wide, NC308 has not give errors.
What i wrong?
A couple of observations...
First off, you need to use 0x12345678L (note the L) to create a "long" constant; otherwise you may end up accidentally truncating it.
Second, the m32c is little-endian, so memory contents should be as follows (all hex):
200000 78
200001 56
200002 34
200004 12
If you look at them as 16-bit locations:
200000 5678
200002 1234
If you're not getting these values, it's time to check the hardware. For 16-bit memory, make sure you did NOT use the A0 address line. Also, double check your timing. Try this program (assuming you have a suitable printf), first WITHOUT the pragma (to see how it should work), then WITH (to test the memory connections):
#include <stdio.h>
unsigned long x;
main()
{
unsigned char *cp;
int i;
x = 0x12345678;
cp = (unsigned char *)&x;
for (i=0; i<4; i++)
printf(" %02x", cp[i]);
printf("\n");
}
Thanks for reply.![]()
I solve problem. In sect308.inc i change a far RAM data area address and declare varable in that way:
far unsigned long x;
This work fine. ![]()
©2003–2009 Renesas Technology Corp. All rights reserved. Using Our Website | Privacy
Contact us