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.
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.
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
>
> 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.
>
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.
>
> 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-transmi
> ts%2C-but-single-bytes-don%27t...-tp20326923p20326923.html Sent from the PIC -
> [PIC] mailing list archive at Nabble.com.
>
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.
> 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 <dt99jayKILLspamgmail.com> wrote:
>
> >
> > 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.
> >
> > --
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.