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

Can PIC receive Serial data with 2 stop bits ?
Goto page Previous  1, 2, 3
 
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

PostPosted: Tue Jun 27, 2006 8:25 am     Reply with quote

Yes PCM Programmer I have the Software Prototype Board YOU mentioned .

Here is Some Update.

I tried an experiment to simulate 7 Data Bits Even Prity , 2 Stop Bits with and other PC and in the Hyperterminal I cinfigured as above.

I connect the PC to the Proto type Board which has a second MAX RS232 Connection as can be seen in the Circuit Link http://www.geocities.com/knisar/RS232.html

The Output fron this PC went to the Input that is connected to the PIC On the Protype Board .

And Guess what Mark! is totaly Right PIC doesnt care about the 2nd Stop Bit.

When i type on the Other PC Hyperterminal The charecter Is echoed on the CCS RS232 Monitor.

So its is Proved PIC doesnt care about the 2nd Stop Bit . And it also works with 7 Bits .

However i am back to square one because i still get Garbage when i connect the RS232 Module.

The Module is working fine because when i connect it to the Hyperterminal I get correct data. so i am baffled now Crying or Very sad

The RS232 Module circuit can be seen here http://www.geocities.com/knisar.

So the sinario is PIC i working . Software is working .
Module and Hypertiminal is working.

But PIC and Module dont like each other .!

Any Sugestions ?
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Tue Jun 27, 2006 8:36 am     Reply with quote

Here is the data Sheet for the Module . I dont know if i have missed any thning !


1. Introduction

The serial interface consists of one data input line and one data output line.
The data traffic speed of the serial interface is 300 bps. Because of the
limited resources of the RC Clock micro-controller only an easy software
protocol can be used. There are no hand shake lines. Synchronising to the
host is by means of the character echo.

2. Voltage supply of the serial interface

The RC Clocks with serial interface are battery operated radio controlled
clocks which are powered by two 1.5V cells. This ensures a battery life of
approximately two years. The voltage supply of the serial interface is
independent of these batteries.
The RS232 serial standard interface consists not only of the serial input
(RxD) and output (TxD) lines but also some additional lines which are used
in some applications for handshaking purposes, the RC Clock uses these
additional lines to supply its internal serial interface circuit with the
required electrical voltage. These additional lines are not needed for data
exchange.
The RC Clock requires both a positive and a negative voltage out of the
PC's serial interface.

The positive voltage is supplied by the DTR line.

There are two ways of providing the negative voltage:

a) The PC "communicates" with the RC Clock by sending ASCII characters
to the RC Clock as described below (see 5.). This allows the negative
voltage to be provided by the TxD line. When the PC sends characters this
line is toggled between a positive and negative voltage level. If the PC
is waiting for the RC Clock to reply the TxD line is always low at a
negative voltage. The RC Clock does not need the TxD negative voltage
while receiving characters only while sending.

b) The RC Clock can be triggered to transmit the time/date
information by pulling the data input line to high voltage level as
described below (see 3.3). This line must be held high until the data
transmission out of the RC Clock has begun. Therefore it cannot supply
the negative voltage. The possibility exists to supply the negative
voltage out of the RTS line. This line must be set to low level by
the programmer who wants to cause the RC Clock to transmit the time/date
information by holding TxD at high voltage level.

3. Data word format

3.1. Data transmitted to the RC Clock

3.1.1. Interface parameters

a) MSF Version
Speed: 300 bps
Data Bit Count: 7
Parity: even, odd, mark, space
(not checked by the RC Clock)
Stop Bit Count: 2

3.1.2. Function of data input

The RC Clock accepts commands of up to three characters, including
its parameters. The character carriage return (hex 0d) causes the RC
Clock to execute the command. Only the four lower bits of each command
and parameter character are used. For instance the characters "?", "O"
and "o" have the same effect. The exception is the final carriage return
which is completely decoded by considering the seven lower bits (MSF
version) resp. all of the eight bits (DCF77 version).

3.2. Replies of the RC Clock
3.2.1. Interface parameters

Speed: 300 bps
Data Bit Count: 7
Parity Bit: even
Stop Bit Count: 2

3.2.2. Function of data output

The reply of the RC Clock consists of a sequence of ASCII characters
terminated by a final carriage return character <cr>.
The character set used by the RC Clock is limited to the numbers
0 ... 9 and the characters : ; < = > ?. The information is contained
within the four lower bits.
The bits 4 and 5 of every reply character are binary ones, the bit 6 is
binary zero and the bit 7 contains the even parity bit. This results in
the sixteen different characters transmitted by the RC Clock, as
described above.
The serial output of the RC Clock can not be interrupted during its
reply. Therefore all characters must be taken by the host computer
immediately.

3.3. Support of a simplified data exchange

A simplified data exchange is possible.
The time/date information transmit command (( o <cr> ) see below 5.1.) is
not the only way to initiate a sequence of ASCII characters. A simpler
method is to pull the TxD (TxD of the PC) voltage level high. Normally
TxD voltage level is low (inactive). If the TxD line is high at the start
of a second then the RC Clock will transmit its time/date information.
This can takes up to one second because the first start bit of the time/date
information sets the beginning of a second. If the TxD line is held high
continually then the RC Clock will transmit the time date information
every second. But care must be taken: The current consumption of the RC
Clock increases during the time/date information output (duration
approximately. 600 ms) up to 200 æA.

4. Handshaking

Every character received by the RC Clock is echoed. The next character
must not be transmitted to the RC Clock before the echo of the preceding
character and an additional duration of 10 ms.
Recognising input characters is by checking the correct appearance both
of the start bit and the two stop bits. The eight echoed data bits remain
unchanged under all circumstances, regardless whether or not parity is
even or odd.

5. Description of commands

The commands 5.5. to 5.9. (set and read alarm times) are related to
desktop alarm-clocks.

5.1. Transmit time/date information

syntax ASCII: o <CR>

Character "o" may be replaced if necessary by a character whose code contains
the lowest four bits f(hex), e.g. also / ? O _

syntax binary: xxxx1111 00001101

The RC Clock replies to this command with a sequence of 15 characters
which contain the complete time information and a final <cr>. Making 16
characters in total.
The RC Clock will not reply immediately to this command because the
start bit edge of the first reply character marks the beginning of the
second. So the RC Clock will reply to this command at the start of the
next second.

The characters have the following meaning:
1. hours tens
2. hours units
3. minutes tens
4. minutes units
5. seconds tens
6. seconds units
7. day of week 1 (Monday) ... 7 (Sunday)
8. day of month tens
9. day of month units
10. month tens
11. month units
12. year tens
13. year units
14. BST/UTC status
bit7 parity
bit6 always 0
bit5 always 1
bit4 always 1
bit3 always 0
bit2 =1 if UTC is in effect, complementary to the BST bit
bit1 =1 if BST is in effect, according to the BST bit
bit0 BST/UTC change impending bit =1 in case of change impending
15. status
bit7 parity
bit6 always 0
bit5 always 1
bit4 always 1
bit3 =1 if low battery voltage is detected
bit2 MSF Version : don't care
DCF77 Version: =1 if the first reception attempt failed
and still no valid time information exists
(bit0 = 0)
The first succsessful reception attempt resets
this bit.
bit1 =1 if at least one reception attempt since 2:30 am (MSF
Version) resp. 3:00 am (DCF77 Version) was successful
=0 if no reception attempt since 2:30 am (MSF Version) resp.
3:00 am (DCF77 Version) was successful
bit0 =1 if the RC Clock contains a valid time information
This bit is zero after reset and one after the first
successful reception attempt.

5.2. Transmit reception status

syntax ASCII: g <CR>

Character "g" may be replaced by a character whose code contains the
lowest four bits 7, e.g. also ' 7 G W w

syntax binary: xxxx0111 00001101

The reply to this command consists of two characters and the final <cr>.
The characters have the following meaning:
1. Status of reception
bit7 parity
bit6 always 0
bit5 always 1
bit4 always 1
bit3 always 0
bit2 always 0
bit1 always 1
bit0 =0 if no reception attempt takes place at the moment
=1 if a reception attempt takes place at the moment
2. reception quality characterising number from 0 to 5
5 indicates a good reception without any disturbances
0 indicates very poor reception conditions
If the number is in the range from 0 to 2 no successful
reception is to be expected normally.
During reception pauses this number is always 0.

5.3. Start reception attempt including time comparison

syntax ASCII: h <CR>

Character "h" may be replaced by any other character whose code contains
the lowest four bits 8, e.g. also ( 8 H X x

syntax binary: xxxx1000 00001101

This command causes the RC Clock to activate the receiver IC and to
start a reception attempt which includes input of the complete MSF resp.
DCF77 time information and synchronising the RC Clocks internal time
according to the MSF resp. DCF77 second pulses. The accuracy is better
than 20 ms.
If this attempt ends unsuccessfully from 2:00 am to 3:00 am bit 1 of the
15th time/date information character will be reset (see 5.1.). This bit is
always set after ending the reception attempt successfully.

5.4. Start reception attempt without time comparison

syntax ASCII: i <CR>

Character "i" may be replaced by any other character whose code contains
the lowest four bits 9, e.g. also ) 9 I Y y
syntax binary: xxxx1001 00001101

This command causes the RC Clock to activate the receiver IC and to
start a reception attempt. Only the internal seconds timing will be
synchronised according to the MSF resp. DCF77 seconds pulses. The accuracy
is better than 20 ms. Setting of status bits is in accordance to 5.3.
Attention: If the preceding reception attempt was unsuccessful or if this
command appears from 12:00 am to 3:00 am it will cause a reception attempt
which includes complete time comparison (see 5.3.)


6. Testing of the interface

By means of a simple terminal program the function of the serial interface
can be tested. Here are parameters for Windows Terminal which are analogous
to other terminal programs:
- 300 Baud data speed
- 7 data bits
- Parity "space"
- 2 stop bits
- Protocoll none
- Interface: depends on the chosen serial interface (e.g. Com1:)
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Tue Jun 27, 2006 8:51 am     Reply with quote

Sorry there is a dot in this link which shouldnt be there

http://www.geocities.com/knisar
Ttelmah
Guest







PostPosted: Tue Jun 27, 2006 9:38 am     Reply with quote

Obvious comment. Check with a meter, or by eye, that the connections you have used, do actually go to a MAX232. I must admit, I'd have thought a connection marked 'C6/C7', would actually go to the processor pins, in which case the signals will be inverted from what is needed.

Best Wishes
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Tue Jun 27, 2006 9:51 am     Reply with quote

Response to Ttlmah connections have been checked . and yes C6 and C7 to to the Pins .

I am going to get an inverter and put it in the middle and will let you know the result . soon
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Tue Jun 27, 2006 10:43 am     Reply with quote

deltatech wrote:
Response to Ttlmah connections have been checked . and yes C6 and C7 to to the Pins .

I am going to get an inverter and put it in the middle and will let you know the result . soon


I don't think an inverter will do the trick. You will most likely need a MAX232 chip.

Quote:
If the PC
is waiting for the RC Clock to reply the TxD line is always low at a
negative voltage. The RC Clock does not need the TxD negative voltage
while receiving characters only while sending.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Tue Jun 27, 2006 11:45 am     Reply with quote

deltatech wrote:
Quote:

So the sinario is PIC i working . Software is working .
Module and Hypertiminal is working.
But PIC and Module dont like each other .!


According to this schematic:

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

1) could you tell us where did you connect the PC?
2) could you tell us where did you connect the PIC?
3) just a curious, in what country do you live and from what station are you receiving the synchronizer signal ?


Humberto
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Tue Jun 27, 2006 11:58 am     Reply with quote

Hi Humberto I connected the PIC to PIN Ser Outt after the BC557 .

In other words Between BC557 and MAX232 . Where it says TTL .
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Tue Jun 27, 2006 12:01 pm     Reply with quote

Hi Mark there is already a MAX232 chip on the Software Prototyping Board . I thought YOu need Max232 to to talk to the PC and not the PIC .
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Tue Jun 27, 2006 12:05 pm     Reply with quote

Quote:

In other words Between BC557 and MAX232 . Where it says TTL .


It´s Ok, but you must open the path to the MAX232.
In other words:
PIN_C6 should be wired to the resistor base of the BC557 ONLY.
PIN_C7 should be wired to the collector of the BC547 ONLY
+ a pull up resistor
(2K2 to 10K) wired to +5V

Humberto
Ttelmah
Guest







PostPosted: Tue Jun 27, 2006 3:23 pm     Reply with quote

deltatech wrote:
Hi Mark there is already a MAX232 chip on the Software Prototyping Board . I thought YOu need Max232 to to talk to the PC and not the PIC .


The data sheet you have posted, is talking about a device designed to talk to RS232. RS232, _is a voltage signalling standard, developed by driver chips like the MAX232_. The PIC, _does not_ itself generate RS232. It generates TTL serial. If the unit works, connected to a PC (you report it does), then it requires RS232, and will require to be connected to the MAX232, _not_ to the TTL serial lines.

Best Wishes
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Tue Jun 27, 2006 3:33 pm     Reply with quote

Ok I have got a inverter connected as said by Ttelmah . And I am no longer getting graphic charecters . I have also placed a 5.5K pull up resister on the BC547 Collecter as mentioned by Humberto and I am getting this now .

It looks like its almost there because the out put is almost same and there is a 2 wich is part of the time from 2230 ects .

Code:
\0A06/27/2006 22:26:19.062 --> Buffered data => 2'$ffff"&2'f$ffff"&2'   $ffff"&\0D 
\0A06/27/2006 22:26:22.265 --> Buffered data => 2'e$ffff"&2'2$ffff"&2'$$ffff"&\0D   
   06/27/2006 22:26:25.437 --> Buffered data => 2'Db"bffff"&2'c$ffff&2fb"bffff"&2'$f
\0A"\0D                                                                             
\0A06/27/2006 22:26:29.031 --> Buffered data => &2$ffff"&2f$ffff"&2     $ffff"&\0D 
\0A06/27/2006 22:26:32.265 --> Buffered data => 2e$ffff"&22$ffff"&2$$ffff"&\0D     
   06/27/2006 22:26:35.421 --> Buffered data => 2Db"bffff"&2c$ffff&2ffb"bffff"&2f'$f
\0A\0D                                                                             
\0A06/27/2006 22:26:38.984 --> Buffered data => "&2f$ffff"&2ff$ffff"&2f $ffff"&\0D 
\0A06/27/2006 22:26:42.250 --> Buffered data => 2fe$ffff"&2f2$ffff"&2f$$ffff"&\0D   
   06/27/2006 22:26:45.421 --> Buffered data => 2fDb"bffff"&2fc$ffff"&2 fb"bffff"&2b
\0Affff"&\0D                                                                       
   06/27/2006 22:26:49.125 --> Buffered data => 2       $ffff"&2        fb"bffff"&2$
\0Af"&\0D                                                                           
   06/27/2006 22:26:52.281 --> Buffered data => 2       $ffff"&2        2$ffff"&2  b
\0Affff"&\0D                                                                       
   06/27/2006 22:26:55.453 --> Buffered data => 2       Db"bffff"&2     Lb"bffff&2ef
\0Affff"&2e'$ffff"&\0D                                                             
\0A06/27/2006 22:26:59.109 --> Buffered data => 2e$ffff"&2ef$ffff"&2e   $ffff"&\0D 
\0A06/27/2006 22:27:02.281 --> Buffered data => 2ee$ffff"&2e2$ffff"&2e$$ffff"&\0D   
   06/27/2006 22:27:05.437 --> Buffered data => 2eDb"bffff"&2ec$ffff&$ffb"bffff"&$&b
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
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