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

RS232 driver

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



Joined: 22 Dec 2003
Posts: 82

View user's profile Send private message

RS232 driver
PostPosted: Wed Jul 28, 2004 1:15 am     Reply with quote

Hi,

I want to send & receive strings to a controller via RS232.
I'm using PIC 16F877A.
I have to send it a control string like ("AT") : printf("at\r\n");
The controller return every char as echo and add his response string like : "OK" or "OK 1234".
I'm looking for C code that can check the response (ignore the echo).
The receive must be complete string and interupt driven.

Thanks in advance.
Edi
carlosma



Joined: 24 Mar 2004
Posts: 53
Location: Portugal

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

PostPosted: Wed Jul 28, 2004 4:53 am     Reply with quote

Hello
I make something similar. But when send a printf"AT... , I disable interrupt #int_RDA. Now I do not read the echo.
enable_interrupt when I need to read from RS232.

Carlos
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

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

PostPosted: Sat Jul 31, 2004 11:23 pm     Reply with quote

You have to decide how many characters you want to receive, or you must send a specific character like EOF, etc. which will signify that the data transmission has ended, check your controller and see if it sends this end of data transmission character.

The following code should give you an idea.

I have assumed total characters to be 5, and end of transmission character as EOF. (13 )


You must paste this code extract to your program.
Also after receiving the data you must check manually for the required string.

thank you
arun



char dt(5);
int n;

#int_RDA

rs232()

{

char c;

c=getc();

if (c!=13)
{
dt(n)=c;

n++;

if (n>5)
{
n=0;
// The buffer is full, clear the buffer and start again. Also execute rest of the code.

}

}


}
Guest








PostPosted: Sun Aug 01, 2004 1:55 am     Reply with quote

Thanks,

Edi
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