EmbeddedRelated.com
Forums

Help with PIC32 Virtual Ram pointer

Started by linnix October 7, 2012
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.

linnix wrote:
> 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. >
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
On Sunday, October 7, 2012 12:18:58 PM UTC-7, Jamie wrote:
> linnix wrote: > > > 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. > > > > > > > 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
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"; }
On Oct 9, 7:26�pm, m...@linnix.info-for.us wrote:
>snip< > Using serial port. &#4294967295;Accessing the variable immediately lockup the processor. &#4294967295;I trust serial port more than Jtag or SPI debugger. > > int Virtual_ram; > > main() > { > &#4294967295; &#4294967295; &#4294967295; &#4294967295; char s[100]; > &#4294967295; &#4294967295; &#4294967295; &#4294967295; sprintf(s, "%x\n", &Virtual_ram); > &#4294967295; &#4294967295; &#4294967295; &#4294967295; PutS(SERIAL_CONSOLE, s); > > &#4294967295; &#4294967295; &#4294967295; &#4294967295; Virtual_ram = "CRASH AND BURN HERE"; > > > > }- Hide quoted text - >
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.
> > Since Virtual_ram is not used for anything the compiler doesn't have > > to allocate it any (valid) address.
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.
> > > > Try volatile Virtual_ram, or print its value or both.
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<1000000; i++) Nop(); } }