Dear All,
I'm trying to recompile some c code that was initially with IAR in gcc. My
function that doesn't work, is supposed to write characters to a serial
port.
The prototype of my function to write to a serial port, is:
void put_message( unsigned char *s);
I then call this function like so:
put_message( "TEST");
If I put a breakpoint inside the put_message function and examine the value
of *s, I get 0. I've examined the "memory map" around s in gcc, and the
memory locations after s are also set to 0.
Does gcc not like unsigned char pointers?
Here's a small snippet of code where the problem occurs:
#include <msp430x42x.h>
void put_message(unsigned char *msg){
msg[0]++;
msg[0]++;
msg[0]++;
msg[0]++;
}
int main(void){
int i = 0;
unsigned char message[10];
message[0]=1;
message[1]=2;
message[2]=3;
message[3]=4;
P1SEL = 0;
P1DIR = P1DIR | 0x8;
while (1){
P1OUT = P1OUT | 0x8;
for (i=0;i<1000;i++){}
P1OUT = P1OUT & 0xf7;
for (i=0;i<1000;i++){}
put_message(message); //neither of these function calls produce the
correct value in put_message
put_message("test");
}
}
Do you have any suggestions? Thanks in advance for your help,
Regards,
Alan
--
View this message in context:
http://www.nabble.com/passing-a-pointer-to-a-function-with-MSP430-gcc-tf4278688.html#a12178517
Sent from the MSP430 gcc - Users mailing list archive at Nabble.com.