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

How to send a "BREAK" to a modem?

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



Joined: 15 Sep 2003
Posts: 36

View user's profile Send private message

How to send a "BREAK" to a modem?
PostPosted: Wed Sep 15, 2004 8:45 am     Reply with quote

Hello,

I'm using a PIC18F252 interfaced to a Wavecom modem (GSM/GPRS), I'm only using the TX, RX and GND (RS232) pins of the modem to comunicate with the PIC. Sometimes the PIC looses comunication with the modem, maybe because I'm using software uart or maybe because the other pins are not used (CTS, RTS, DTR, DSR).

Anyway, I put a check subroutine that will check if communication is ok every minute sending an AT command to the modem, if it responds OK then everything is working well, otherwise I want to send a BREAK to the modem to reset the TX and RX lines...

Hope is clear enough.
Thank you in advance
Peter
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed Sep 15, 2004 8:54 am     Reply with quote

As <break> is not an ASCII character you will have to bit-bang it. Between chars the line should be at Stop bit level. Set it to Start bit level for 10ms (IIRC) and then back to Stop bit level. That is all there is to it.
_________________
The search for better is endless. Instead simply find very good and get the job done.


Last edited by SherpaDoug on Wed Sep 15, 2004 10:05 am; edited 1 time in total
runtime



Joined: 15 Sep 2003
Posts: 36

View user's profile Send private message

PostPosted: Wed Sep 15, 2004 9:06 am     Reply with quote

hello SherpaDoug,

what do you mean for "Stop bit level" and "Start bit level", and what line should I use, TX or RX?

Thanx
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed Sep 15, 2004 9:27 am     Reply with quote

You are sending the <break> to the modem so you would use the TX line. Normally Start is a logic 0 and Stop is a logic 1, unless you are using the "invert" software UART option option.
_________________
The search for better is endless. Instead simply find very good and get the job done.
runtime



Joined: 15 Sep 2003
Posts: 36

View user's profile Send private message

PostPosted: Wed Sep 15, 2004 10:04 am     Reply with quote

Hi SherpaDoug,

you said "Between chars the line should be at Stop bit level. Set it to Start bit level for 10ms (IIRC) and then back to Start bit level. That is all there is to it."

should it be: Set it to Start bit level for 10ms (IIRC) and then back to Stop bit level ?

thank you
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed Sep 15, 2004 10:06 am     Reply with quote

Yes, you are right. I corrected my post.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Guest








PostPosted: Wed Sep 15, 2004 11:05 am     Reply with quote

Don't worry about modem handshake signals.
Just connect pins 7-8 (one short circuit) and 11-12 (another short) (assumed that you use Fastrack series and not the Integra line Smile ).
Jeff King



Joined: 20 Oct 2003
Posts: 43
Location: Hillsdale, Michigan USA

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Sep 15, 2004 4:22 pm     Reply with quote

You also need to turn the uart off to gain control of the pin, if using a hardware uart. There is a command in CCS to do it or you can do it direct.
Kieran



Joined: 28 Nov 2003
Posts: 39
Location: Essex UK

View user's profile Send private message

PostPosted: Thu Sep 16, 2004 5:17 am     Reply with quote

How about putc(0xFF); ?
Should send a start followed by stop level for one char duration.
saves the Tx pin bit banging.
Ttelmah
Guest







PostPosted: Thu Sep 16, 2004 5:53 am     Reply with quote

Kieran wrote:
How about putc(0xFF); ?
Should send a start followed by stop level for one char duration.
saves the Tx pin bit banging.

A 'break', in the defintions, _must_ last longer than one character time (to avoid it being mistaken for the 'real' character represented by 0xFF).
Potentially, you could send a break (if you were operating at 9600bps), by coding something like:
set_uart_speed(110);
putc(0xFF);
set_uart_speed(9600);

which would potentially result in a 'zero' character being received, followed by a 72mSec 'break', which is enough for some standards (some require 128mSec).

Best Wishes
Guest








PostPosted: Thu Sep 16, 2004 6:10 am     Reply with quote

Maybe 0x00 would be better. Sending 0xFF contains only one-bit time of break level (the start bit itself).
Mark



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

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

PostPosted: Thu Sep 16, 2004 2:15 pm     Reply with quote

edit
Ttelmah
Guest







PostPosted: Fri Sep 17, 2004 2:00 am     Reply with quote

Anonymous wrote:
Maybe 0x00 would be better. Sending 0xFF contains only one-bit time of break level (the start bit itself).

Aargh!.
I just followed the 'level' suggested by the other poster, and didn't think to check which way the signalling should be...
This actually 'improves' things (since the start bit and data are the same level), and should make this a simple/reliable way to send a stop without having to do bit banging. :-)

Best Wishes
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