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

rs232 conflicts

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



Joined: 02 Apr 2008
Posts: 36

View user's profile Send private message

rs232 conflicts
PostPosted: Tue Apr 15, 2008 2:37 pm     Reply with quote

i have the following setting:

Code:

#use rs232(baud=4800, bits=8, parity=N, stop=1, xmit=PIN_C6, rcv=PIN_C7, stream=GSM, ERRORS)



but when i use the follow functions:

Code:

void my_get_string(void) {

  char c;
  int i=4;
  int count=0;
  unsigned char temp[68]="$GPR";

output_low(PIN_B7);
delay_ms(500);
start:

c = getc();
if(c == '$')
{
   output_high(PIN_B7);
   output_low(PIN_B7);
   c = getc();
      if(c == 'G'){
        //  output_low(PIN_B7);
          output_high(PIN_B7);
          //output_low(PIN_B7);
          c = getc();
             if (c == 'P'){
                  c = getc();
                  if (c == 'R'){
                     output_high(PIN_B7);
                           while(count < 55){
                              temp[i]= getc();
                              i++;
                              count++;
                              }

        goto ending;
/*
         back:
         output_high(PIN_B7);
         goto back;*/
             }
        }
   }
}


goto start;

ending:
temp[i] = 0;
cursor_position(0x81);
out_lcd_string(temp);
delay_ms(1500);

}


and

Code:
void gsm_call(void)
{

char c;

output_low(PIN_B5);
delay_ms(800);
output_low(PIN_C4);
output_high(PIN_C5);
delay_ms(500);

fprintf(GSM, "AT+CMGF=1\r\n");
delay_ms(2050);
fprintf(GSM,"AT+CMGS=\"%s\"\r\n",num);
delay_ms(2000);
fprintf(GSM, "check\r\n");
fputc(0x1A,GSM);
delay_ms(3000);
}


the my_get_string function stops working but the gsm_call continues to work correctly.

however, when i comment stream=GSM out of the configuration, the my_get_string works.

Is there a reason that this is happening?
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Tue Apr 15, 2008 3:04 pm     Reply with quote

RS232 is asynchronous. While you are fprinting chars you must must must be able to receive chars at that exact and very instant. That means while you are printing even a single bit of a char you must be able to receive a char. With out flow control to synchronize your input your output will have great potential to corrupt your input.
Search this forum and look at circular buffers and the #intRDA and isr.
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