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 Protocol not working

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



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

RS232 Protocol not working
PostPosted: Fri Jun 16, 2006 11:49 am     Reply with quote

Hi I am trying to communicate with the following circuit . if you click on this link you can see it. www.geocities.com/knisar

The RS232 module works with following settings .

Speed 300
Data Bit Count 7
Parity Even, odd, mark, space
Stop Bit count 2


I have tried the following bit of code . But all i am getting on the monitor is a C .

Can any one please tell me what i am doing wrong .


Code:

#include "F:\Program Files\PICC\Project\MSF\MSF.h"

#use rs232(debugger,baud=300,parity=E,rcv=PIN_C7,bits=7,stream=MSF)

#include <input.c>
#include <stdlib.h>
void main()
{


   while(TRUE)
   {
      char c;

      c=fgetc(MSF);
       printf("%s",c);
   }


}


http://www.geocities.com/knisar
grasspuddle



Joined: 15 Jun 2006
Posts: 66

View user's profile Send private message

PostPosted: Fri Jun 16, 2006 12:18 pm     Reply with quote

what are you expecting to recieve?

it seems to me that it gets one char 'c' then hangs waiting to recieve another char.

for chars i usually use
Code:

fprintf(MSF,"%C",c);


instead of %S

thats all i can think of Confused
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Fri Jun 16, 2006 12:48 pm     Reply with quote

according to the datasheet there should apear 15 ascii charecters when a o + cr is sent to the rs232 module . or the tx line is helh hich permentaly
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Fri Jun 16, 2006 1:13 pm     Reply with quote

grasspuddle i have tried but still i get a C on the monitor .

There should be 15 ASCII charecters mostly numbers .
Ttelmah
Guest







PostPosted: Fri Jun 16, 2006 4:41 pm     Reply with quote

There are a whole series of seperate 'issues' here.
First,the PIC cannot generate 2 stop bits. If you need this, then you will have to set the data bits to 8, and 'pad' the characters with an extra '1' at the end.
Second, is this pin being used for the debugger or to talk to another unit?. You can't use the same pin for both operations, and if it is used for a debugger you still have to set both the transmit, and the receive pins (just to the same value).
Third, as has already been pointed out, '%s', is an incorrect printf declaration. This prints a _null terminated_ string. You do not have a null terminated string...
You speak of the unit sending 15 characters when an 'o' + CR is sent to it, but there is no sign of these characters being sent.
Though declaring a variable inside an internal routine, is acceptable in C, it is not really supported in CCS C. It may cause issues.

Best Wishes
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Sat Jun 17, 2006 1:27 pm     Reply with quote

I have corrected the code with fprintf(MSF,"%C",c); but still i only get a C on the monitor.

As pointed out by Ttelmah that the pins cannot be used for both the module and the monitor.

How do i get an indication if the module is sending data or not if i cant use the pins to display the output on the monitor.

Is is possible to talk to the RS232 module and display the data any other way . ?
Eugeneo



Joined: 30 Aug 2005
Posts: 155
Location: Calgary, AB

View user's profile Send private message

Re: RS232 Protocol not working
PostPosted: Sat Jun 17, 2006 3:37 pm     Reply with quote

7bits+1parity+2stop = 10 bits

You're going to have to use the LONG_DATA (9data 1stop) with no hardare usart.
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