CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

trouble wiht pointers

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
bertronicom



Joined: 17 Nov 2004
Posts: 26
Location: University of Cantabria -SPAIN

View user's profile Send private message Send e-mail MSN Messenger

trouble wiht pointers
PostPosted: Thu Apr 28, 2005 2:57 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Apr 28, 2005 3:26 pm     Reply with quote

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

View user's profile Send private message Send e-mail

Re: trouble wiht pointers
PostPosted: Thu Apr 28, 2005 3:57 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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