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

hardware uart does not receive all the characters

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



Joined: 12 Sep 2008
Posts: 4

View user's profile Send private message

hardware uart does not receive all the characters
PostPosted: Fri Sep 26, 2008 9:02 am     Reply with quote

Hi,

I have a problem with the hardware uart of the PIC16F877A. The UART is connected to a powerline modem (ST7538).

The problem is that I only receive the last characters of the string. I send a string of about 20 characters, the first 10 are not received. I checked the RX pin of the PIC with a scope. The characters I use the #INT_rda interrupt to receive the characters.

here is my interrupt routine:


Code:
#int_RDA
void RDA_isr()
{
byte data = 0;
   if(kbhit(COM1))
   {
      data = getc(COM1);
      if(data)
      {
         fputc(data,COM2);
         write_buffer((buf_t *)&rcv_buffer,data);
      }
   }   
}


COM2 is a software UART. write_buffer is a function which puts the data in my buffer and checks for control characters. Here is the function:

Code:
boolean write_buffer(buf_t *buffer, byte data)
{
   if(!buffer->full)
   {
      buffer->data[buffer->wr_idx] = data;
      switch(data)
      {
         case '$':
            buffer->rcvd_dollar = true;
            buffer->dollar_position = buffer->wr_idx;
            break;
         case '*':
            buffer->rcvd_star = true;
            buffer->star_position = buffer->wr_idx;
            break;
         case '\n':
            buffer->rcvd_nl = true;
            buffer->nl_position = buffer->wr_idx;
            break;
         default:
      }
      buffer->wr_idx++;
      if(buffer->wr_idx >= RCV_BUF_SIZE)
      {
         buffer->full = true;
      }
      return true;
   } else {
      return false;
   }
}


I use the following statement to configure the UART:

Code:
#use rs232(baud=600,UART1,stream=COM1,errors)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Sep 26, 2008 11:26 am     Reply with quote

Do some tests. Comment out the fputc() for the software UART, inside
the INT_RDA isr. Dump the buffer after you've sent a string.
Did you get it all, this time ? If so, the problem is in the fputc() inside
the isr. What's the baud rate for the soft UART ? You didn't post the
#use rs232() statement for that one.
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