View previous topic :: View next topic |
Author |
Message |
deltatech
Joined: 22 Apr 2006 Posts: 87
|
RS232 Protocol not working |
Posted: Fri Jun 16, 2006 11:49 am |
|
|
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
|
|
Posted: Fri Jun 16, 2006 12:18 pm |
|
|
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 |
|
|
deltatech
Joined: 22 Apr 2006 Posts: 87
|
|
Posted: Fri Jun 16, 2006 12:48 pm |
|
|
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
|
|
Posted: Fri Jun 16, 2006 1:13 pm |
|
|
grasspuddle i have tried but still i get a C on the monitor .
There should be 15 ASCII charecters mostly numbers . |
|
|
Ttelmah Guest
|
|
Posted: Fri Jun 16, 2006 4:41 pm |
|
|
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
|
|
Posted: Sat Jun 17, 2006 1:27 pm |
|
|
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
|
Re: RS232 Protocol not working |
Posted: Sat Jun 17, 2006 3:37 pm |
|
|
7bits+1parity+2stop = 10 bits
You're going to have to use the LONG_DATA (9data 1stop) with no hardare usart. |
|
|
|