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 CCS Technical Support

Array pointer increment

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



Joined: 12 Jun 2006
Posts: 19

View user's profile Send private message

Array pointer increment
PostPosted: Mon Jun 12, 2006 1:57 pm     Reply with quote

Hi :

Why in this code the array index "next_in" increments automaticaly when there is an interrupt.

Why when I try to fill the arrays buffer and buffer_temp they got dferent data?



Code:
#int_rda
void rx_serial_data()
{
byte t;
char ch;

count +=1;
ch=getc();
buffer[next_in] =ch; // get the data(single character) from serial port
buffer_temp[next_in]=ch;
t=next_in;
if (buffer[next_in]=0x0A)
++count_lf;
if (count_lf=2)
end_message=true;
next_in=(next_in+1) % BUFFER_SIZE;
if(next_in==next_out)
next_in=t; // Buffer full !!
}



Sending a "AT" command to a GSM modem, this is what I got using the ICD2
Code:
   
   Address    Symbol Name Value Hex  Char

     0029    next_in      0x06 0x06      .
     0055    end_message  0x01           
     002B    BUFFER      ""           
     002B    [0]             . 0x0A      .
     002C    [1]             . 0x0A      .
     002D    [2]             . 0x0A      .
     002E    [3]             . 0x0A      .
     002F    [4]             . 0x0A      .
     0030    [5]             . 0x0A      .
     0031    [6]             . 0x00      .
     0032    [7]             . 0x00      .
     0033    [8]             . 0x00      .
     0034    [9]             . 0x00      .
     0035    [10]            . 0x00      .

     00A0    buffer_temp "OK"           
     00A0    [0]             . 0x0D      .
     00A1    [1]             . 0x0A      .
     00A2    [2]             O 0x4F      O
     00A3    [3]             K 0x4B      K
     00A4    [4]             . 0x0D      .
     00A5    [5]             . 0x0A      .
     00A6    [6]             . 0x00      .
     00A7    [7]             . 0x00      .
     00A8    [8]             . 0x00      .
     00A9    [9]             . 0x00      .
     00AA    [10]            . 0x00      .
   
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 12, 2006 2:13 pm     Reply with quote

At a minimum, the lines shown in bold below are wrong.
Quote:
#int_rda
void rx_serial_data()
{
byte t;
char ch;

count +=1;
ch=getc();
buffer[next_in] =ch; // get the data(single character) from serial port
buffer_temp[next_in]=ch;

t=next_in;

if (buffer[next_in]=0x0A)
++count_lf;

if (count_lf=2)
end_message=true;

next_in=(next_in+1) % BUFFER_SIZE;
if(next_in==next_out)
next_in=t; // Buffer full !!
}

Look at item #2 in the link below.
http://www.edm2.com/0504/12cerr.html
ysaacb



Joined: 12 Jun 2006
Posts: 19

View user's profile Send private message

Thank you !!!
PostPosted: Wed Jun 14, 2006 6:13 am     Reply with quote

thank you
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