chipKIT® Development Platform

Inspired by Arduino™

Using pointer will cause the board freeze

Created Sun, 27 May 2012 05:11:33 +0000 by legendary_kx


legendary_kx

Sun, 27 May 2012 05:11:33 +0000

I just bought the chipkit uno32 and I want to use it for rosserial. I able to compile the ros_lib libraries and upload the code into the uno32. When i start the rosserial communication, the board will just hang. I discover that using pointers in uno32, it will cause the board freeze. Rosserial used a lot of pointers in their libraries. I using mpide-023. Below is the example code of using pointers,

After you compile and upload the code, the LED 13 should blink. But the LED 13 does not blink and the board just freeze. Is it the pic32 compiler problem?

boolean change = true;
void setup(){
 pinMode(13, OUTPUT);
 Serial.begin(57600);
 Serial.println("Start");
 delay(1000);
 int * l;
 *l = 10;
 Serial.println(*l);
}

void loop(){
 delay(1000);
 digitalWrite(13, change ? HIGH : LOW);
 change = !change;
}

KurtE

Sun, 27 May 2012 12:45:13 +0000

Nope it is a problem with your program...

That is with your code:

int * l;
 *l = 10;

You say to stuff 10 into the location where l is pointing. But l is not initialized... So it is stuffing it in some random location like 0...

Should be more like:

int ll;
 int * l;
 l = ≪
 *l = 10;

Kurt


legendary_kx

Tue, 29 May 2012 02:24:49 +0000

Thx Kurt. I finally get the rosserial running in my chipkit uno32.


wegunterjr

Sat, 27 Oct 2012 05:28:43 +0000

how did you get it to work? I am able to complie rosserial, but when I upload to the arduino (I am actually using Max32) the Hello World example, and try to look at the connection i lose connection...any luck with that?