Searching \ for '[PIC] EUSART, '18F4550, Continuous stream of bytes' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=usart
Search entire site for: 'EUSART, '18F4550, Continuous stream of bytes'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] EUSART, '18F4550, Continuous stream of bytes'
2008\11\04@130330 by dt99jay

picon face

Should have said that the putch() routine is as the below:

[code]
void putch(unsigned char c){
       do { } while (BusyUSART()); // wait until Usart is not busy
       WriteUSART(c);
}
[/code]

Jamie
--
View this message in context: www.nabble.com/EUSART%2C-%2718F4550%2C-Continuous-stream-of-bytes-transmits%2C-but-single-bytes-don%27t...-tp20326923p20327583.html
Sent from the PIC - [PIC] mailing list archive at Nabble.com.

2008\11\06@045757 by dt99jay

picon face

Hi

I'm picking up some legacy code for a PCB controlled by an '18F4550 and have
got a problem that is confusing me. I'm not v experienced with 18F devices
or C-18, so it may be a silly mistake.

The EUSART transmits via a MAX3080E chip (RS485 transceiver), then down a
short length of cable to an RS485 to USB converter (a USB-COMi-M) and into a
mac running ZTerm. The below code snippet functions fine:
[code]
while(1) {
    putch('x');
}
[/code]
in that it writes a continuous stream of 'x's to ZTerm. If I try to send
individuals bytes, or a short stream, like this:
[code]
    putch('x');
    putch('x');
    putch('x');
[/code]
then I don't get any output on ZTerm. No other settings are changed between
the two experiments. Any ideas why this might be?

RCSTA is set to: b'10010100'
TXSTA is set to: b'10100110'
BAUDCON is: b'01000000'
Baud rate is 19.2k.

The EUSART is running from the internal oscillator, which I know isn't
perfect, but it's an inherited PCB and I can't do much about it.

Many thanks for any pointers.

Btw. I also tried to post this message on the Microchip forums, but it
looked like it got bounced back repeatedly - but in case it later pops up
there, apologies for any double posting.

Jamie


--
View this message in context: www.nabble.com/EUSART%2C-%2718F4550%2C-Continuous-stream-of-bytes-transmits%2C-but-single-bytes-don%27t...-tp20326923p20326923.html
Sent from the PIC - [PIC] mailing list archive at Nabble.com.

2008\11\06@051856 by Marcel Birthelmer

flavicon
face
Jamie,
could it be that the USB chip is somehow buffering the data stream until it
receives a control character such as "\r" or "\n", or enough characters to
fill its internal buffer?
- Marcel

On Tue, Nov 4, 2008 at 10:03 AM, dt99jay <spam_OUTdt99jayTakeThisOuTspamgmail.com> wrote:

{Quote hidden}

> -

2008\11\06@054832 by Ruben Jönsson

flavicon
face
Is the RS485 connected with one pair + ground (half duplex) or with two pairs +
ground (full duplex RS422 mode)?

If it is in half duplex mode you have to make sure that the DE (driver enable)
pin on the MAX3080E is activated (set high) from the software. If it is in full
duplex mode it may still need to be activated by software but then it can also
be clamped high directly on the PCB.

/Ruben


{Quote hidden}

> -

2008\11\06@055332 by Tamas Rudnai
face picon face
Buffering is one thing, also I was thinking about hand-shaking - I don't
know if you have RTS/CTS set up so that the ZTerm is not ready but you are
not listening to these lines and sending your stream anyway - with the
infinite loop at some point the ZTerm gets ready so it will receive some 'x'
chars, but you will never know if you are loosing the beginning (or other
parts) of your stream - you should serialise the stream somehow to figure it
out anyway.

Tamas


On Thu, Nov 6, 2008 at 10:18 AM, Marcel Birthelmer <.....marcelKILLspamspam@spam@carrietech.com>wrote:

{Quote hidden}

2008\11\07@065044 by dt99jay

picon face

Many thanks for the ideas, all. I've done some tests which point towards the
RS485/USB converter rather than anything in the code:

1. The MAX3080E is wired as full duplex, and DE is controlled by software
and set high prior to transmitting.

2. I changed the code to something like this:
[code]
for(i=0;i<200;i++) {
    putintdec(i);
    putch('-');
}
[/code]
and received the full string of all 200 numbers. Same when running the 'for'
loop from 0 to 100. However when running from 0 to 50, 0 to 25 and 0 to 15,
the first six to twelve numbers weren't received.

3. I looked into the USB device and found it had a DIP switch which let me
choose "RS-422 mode: 4-wire with handshaking" which seemed to clear the
problem up.

So it looks as though it was a handshaking problem in the end.

Many thanks again.

Jamie
--
View this message in context: www.nabble.com/EUSART%2C-%2718F4550%2C-Continuous-stream-of-bytes-transmits%2C-but-single-bytes-don%27t...-tp20326923p20379175.html
Sent from the PIC - [PIC] mailing list archive at Nabble.com.

More... (looser matching)
- Last day of these posts
- In 2008 , 2009 only
- Today
- New search...