Help with PIC32 Virtual Ram pointer

The sample thermo.zip at

http://173.224.223.62/pic32

print out the pointer of a global variable.

Linker place it in page A0. Microchip ran it on their simulator and they got the correct result. I ran it on the real chip and got pointer at page 7F

Why, oh, why?

Anyone care to give an explanation? I can lend out a test board if necessary, but right now we are short on hardware.

Reply to
linnix
Loading thread data ...

Looks like a run time error. Code error on pointer math.

It would be interesting as to how you determine it as at page 7F at run time? Using Jtag? Can you really trust that if so ?

Jamie

Reply to
Jamie

Using serial port. Accessing the variable immediately lockup the processor. I trust serial port more than Jtag or SPI debugger.

int Virtual_ram;

main() { char s[100]; sprintf(s, "%x\n", &Virtual_ram); PutS(SERIAL_CONSOLE, s);

Virtual_ram = "CRASH AND BURN HERE"; }

Reply to
me

ssor.  I trust serial port more than Jtag or SPI debugger.

Since Virtual_ram is not used for anything the compiler doesn't have to allocate it any (valid) address.

Try volatile Virtual_ram, or print its value or both.

Reply to
Rocky

Then the compiler is ignoring the statement

Virtual_ram1 = CRASH_AND_BURN_HERE;

But in fact, the processor tries to access the variable and got some exception error.

Yes, i did, but it didn't make any different.

The rest of the program is working fine, including the 802.15.4 RF scanning. However, not having globals means reloading the pointers everytime.

By the way, the scanner is working prefectly and picking up (intercepting) the nearby smart electrical meters.

See: http://173.224.223.62/HomeLink

----------------------------------------------- #define CRASH_AND_BURN_HERE 1 int Virtual_ram1; volatile int Virtual_ram2;

void PhyInit(void); void PhyScan(void);

// main must be first routine int main(void) { int i; //char s[100]; sub1(); PutS(CONSOLE, "PHY layer started\r\n");

sprintf(s, "%x\r\n", &Virtual_ram1); PutS(CONSOLE, s); sprintf(s, "%x\r\n", &Virtual_ram2); PutS(CONSOLE, s);

Virtual_ram1 = CRASH_AND_BURN_HERE;

PutS(CONSOLE, "\r\n"); PutS(CONSOLE, "IEEE 802.15.4 2.4GHz Scanner\r\n"); PutS(CONSOLE, "\r\n");

// This is APP, LLC and MAC layers while(1) { PhyInit(); PhyScan(); for(i=0; i

Reply to
me

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.