|
|
View previous topic :: View next topic |
Author |
Message |
bertronicom
Joined: 17 Nov 2004 Posts: 26 Location: University of Cantabria -SPAIN
|
trouble wiht pointers |
Posted: Thu Apr 28, 2005 2:57 pm |
|
|
I have this code not working,
int8 Decode_BT_Packet ( int *id_Network, *Cmd, *LenData, *CRC ) {
if ( Full_Length_Packet >= 6 ) {
*id_Network = 15;
*Cmd = 16;
*LenData =17;
*CRC = 18;
Ret_Val = 0x01;
}
}
when I'm debugging id_network doesn't have 15 value neither the rest of pointers.
What's happens |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Apr 28, 2005 3:26 pm |
|
|
That's not really a test program. I can't do much with it, so I made
the test program shown below and compiled it with PCM vs. 3.224.
It works. It displays the following characters on the terminal window:
A B C
Code: | #include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
void my_func(int8 *ptr1, int8 *ptr2, int8 *ptr3)
{
*ptr1 = 'A';
*ptr2 = 'B';
*ptr3 = 'C';
}
//================
main()
{
char a;
char b;
char c;
a = 0;
b = 0;
c = 0;
my_func(&a, &b, &c);
printf("%c %c %c", a, b, c);
while(1);
} |
|
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
Re: trouble wiht pointers |
Posted: Thu Apr 28, 2005 3:57 pm |
|
|
bertronicom wrote: | I have this code not working,
int8 Decode_BT_Packet ( int *id_Network, *Cmd, *LenData, *CRC ) {
if ( Full_Length_Packet >= 6 ) {
*id_Network = 15;
*Cmd = 16;
*LenData =17;
*CRC = 18;
Ret_Val = 0x01;
}
}
when I'm debugging id_network doesn't have 15 value neither the rest of pointers.
What's happens |
And it won't! id_network is a pointer. It should have a register address. That register will contain 15. I suggest you brush up on pointers and how they work. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|