|
|
View previous topic :: View next topic |
Author |
Message |
benoitstjean
Joined: 30 Oct 2007 Posts: 566 Location: Ottawa, Ontario, Canada
|
Serial data corruption with Lantronix XPORT - tough one! |
Posted: Thu Dec 13, 2007 9:28 pm |
|
|
My CCS version is 3.224.
I am really stuck. Ok, I have a Lantronix XPORT Ethernet to Serial converter connected to a PIC18F4620's TX and RX pins.
The TX and RX pins on the PIC are connected together because I want to see on a 4x20 LCD display what I transmit and ensure I receive it. I have an infinite while loop that transmits the value of a 0 to 9 counter, followed by a 1 second pause and then I increment the counter by 1. When the counter reaches 9, it resets to 0 and it starts over. When I power-up the device, the LCD will display: 0 (0), 1 (1) and so on.
The first digit is the character received by the RX port and the second in between ( ) is the character I transmitted. This indicates that what I transmit, I receive and this value is the value of my counter. This works perfectly.
Now, my XPORT is a serial to ethernet converter. I connect to the XPORT via Telnet on port 10001 from my PC. If I take my XPORT's RX and TX pins, loop them back together and not connect them in any way to my PIC device, I simply open a Telnet session and connect to the XPORT from my PC via port 10001 through my router, hit a character on my keyboard and the character I pressed is displayed on the screen twice: what I transmitted to the XPORT and what the XPORT received (as it loops-back to itself). This indicates to me that the XPORT can receive and transmit serial data without a problem and it works fine.
So, in brief, I have two serial devices that when looped-back to themselves, what they transmit on their respective TX pin they will both receive the data on the RX pin and re-transmit it. All is fine so far.
Both devices have their serial ports configured the same: 9600 bps, 8N1.
If I take the TX pin on the PIC and connect it to the RX pin on the Lantronix, my PIC can send data to the XPORT's serial side, which in turn will convert it to Ethernet packets, which will then be fired to my PC which in turn will display it in a Telnet window. This works well so far.
The problem: when I connect the TX pin on the PIC to the RX pin on the XPORT and the RX pin on the PIC to the TX pin on the XPORT, this is where I have a problem. The PIC can send data to the XPORT without a problem. But whatever I receive on the XPORT side, the PIC shows me corrupted data. I can do whatever connection I want, even transmitting from the PIC back to itself AND to the XPORT and the same time and that works fine (split my transmit signal so it goes to two places). But anything arriving on from the XPORT, the PIC seems to corrupt it somehow.... but does not corrupt its own data AND the XPORT will receive its own data properly when looped-back....
I am starting to freak-out as everything was working fine until yesterday. I reduced my code, then finally made a new simple TX RX project from scratch and it's just not working. I've never had problems in the past with the XPORT and the PIC. I'm totally out of ideas. I've been working on a project for the last two months with the PICs and the XPORT. Yesterday, I don't know what happened but my communication between the devices stopped functionning. I have 3 XPORT devices and like 6 PIC devices, none of them work like they should. I have two different PIC programmers and both have the same effect. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Dec 13, 2007 10:05 pm |
|
|
Post the test program for the PIC. Post a complete program, showing
the #include, #fuses, and all #use statements. Make it be a short program. |
|
|
Ttelmah Guest
|
|
Posted: Fri Dec 14, 2007 8:22 am |
|
|
Question.
What voltage are you running the PIC?.
The Xport, is I think a 3.3 device. It's inputs are 5v tolerant, but it's output, only goes to +2.4v, which is not high enough to be reliable into the RX pin of the PIC (which requires 0.8*Vcc). If the PIC is on 3.3v, then a pull up resistor on the line is all that is needed. If you are on 5v, then you need a level translator.
For 3.3v operation, on the 4620, you need to be using the industrial vrsion of the chip, and are limited to only 10MHz operation with this chip.
Best Wishes |
|
|
benoitstjean
Joined: 30 Oct 2007 Posts: 566 Location: Ottawa, Ontario, Canada
|
|
Posted: Fri Dec 14, 2007 9:21 am |
|
|
Thanks. I realize that the PIC is 5V and the XPORT is only 3.3V, but it has been working with a very big program for about 2 months. I have a C++ interface on a PC that connects to my XPORT/PIC via ethernet, there's also a phone interface on the circuit that interacts with the PIC.
When it stopped working, I making the order for the parts and the circuit had been up and running for weeks, then nothing. But I know the parts are functional because alone, they work well like they should. I don't have the slightest clue what happened but now it's not working.
I have my PIC and my XPORT on a simple proto-board running the very most basic test code and I cannot get it to work. I have about 5 PICs and I have 3 XPORTs and they all behave the same whichever combination of PIC/XPORT I use. I don't have the circuit in the office, it's at home, but the voltage thing was my next step. I have some voltage level translators.
Anyhow, I really don't see why suddenly it would just stop working when it has been working for two months. I haven't done anything different when it went from the "working phase" to the "non-working phase". Everything is on a proto-board. I even changed the protoboard, the LCD display and the crystal.
So basically:
PIC to PIC (loopback) -> OK
XPORT to XPORT (loopback) -> OK
PIC to XPORT (TX to RX) -> OK
PIC to PIC to XPORT (TX split) -> OK
XPORT to PIC -> bad!
I have also noticed that on occasions, the compiler will crash with some internal error and I have to shut it down and restart it. Even last week, it wouldn't let me compile anymore, I had to re-install it (3.224). I also know that the getc() function, which returns what was captured in the serial buffer, is related to the serial port. I will re-install the compiler tonight (1st step), then use level translators to pump-up the TX pin off the XPORT to make it up to 5V. If I had a 3.3V LCD that would be great because I'd make everything 5V but unfortunately, it's 5V so I have to use 5V. I will then connect the PIC to my serial port on my PC using a MAX233 just to make sure that this works. I will also post the code from the .C and .H files tonight.
Thanks for the heads-up regarding the voltage. |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Fri Dec 14, 2007 9:46 am |
|
|
I ran into this exact problem a while back. I use the XPORT in a few designs with a PIC. You have to convert the levels or it won't work.
Take a look at section 26.3 of the PIC spec. sheet. The input, for the RXD pin is a Schmitt-Trigger. The spec. sheet states that the _minimum_ input voltage is 0.8 VCC. IF you are running at 5V then the minimum input voltage to register a High is 4V. You have been lucky to have things work for two months but I would bet anything that this is your problem.
I've used the MAX3370/3371 voltage level translator and it works great. You have to get that voltage level above 4V or bring your PIC supply voltage down.
Ronald |
|
|
benoitstjean
Joined: 30 Oct 2007 Posts: 566 Location: Ottawa, Ontario, Canada
|
|
Posted: Fri Dec 14, 2007 9:50 am |
|
|
Ok, thank you so much. The charactes coming-in look like the japanese fonts in the HD44780 LCD module's character set but I was not able to identify any based on the spec sheets.
Anyhow, like I said, the voltage level was the next step. And I guess I must have been VERY lucky to have this working for months.... because it really worked like a charm.
I was told by Lantronix support that it should work but I didn't really pay attention to the PIC side, which I should have done. This is far from my first circuit with the PICs but I guess I just didn't pay enough attention, although it is my first time with multiple voltage levels.
Thank you all for your input but more comments/suggestions are always welcome. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Dec 14, 2007 11:21 am |
|
|
Is it possible that you were previously using the Lantronix on PIC pins
that have TTL input levels (as a software UART) ? In that case it would
work. Port B and most of Port A have TTL inputs on the 18F4620. |
|
|
benoitstjean
Joined: 30 Oct 2007 Posts: 566 Location: Ottawa, Ontario, Canada
|
|
Posted: Fri Dec 14, 2007 1:35 pm |
|
|
I am using PIN C7 for RX and PIN C6 for TX. I capture the serial data either using the #int_rda or just in a while loop using kbhit():
while( 1 )
{
if( kbhit() == true )
{
cChar = getc();
lcd_gotoxy( 1, 1 );
printf( lcd_putc, "%C", cChar );
}
}
I will post my exact code tonight but do some voltage-level conversions. |
|
|
benoitstjean
Joined: 30 Oct 2007 Posts: 566 Location: Ottawa, Ontario, Canada
|
|
Posted: Sat Dec 15, 2007 9:47 pm |
|
|
Thanks to everyone. I should have thought of that before but for whatever reason, I oversaw it. I used NVE's IL716 level translators. It worked instantly.
Thank you all for your suggestions and help. |
|
|
Ttelmah Guest
|
|
Posted: Sun Dec 16, 2007 7:31 am |
|
|
Glad it worked.
It is rather a 'classic'. Thinking that becaus it worked for a while, and then went wrong, it had to be software. It appears it must have been pretty much a fluke that it worked at all before (on paper, it seems amazing that it did!).
Best Wishes |
|
|
benoitstjean
Joined: 30 Oct 2007 Posts: 566 Location: Ottawa, Ontario, Canada
|
|
Posted: Mon Dec 17, 2007 7:51 am |
|
|
I just didn't know what could have been wrong. It worked like a charm for months and then suddenly, it stopped working. I suspected the PIC at first but three PICs later, still not working. Tried 3 Lantronix XPORT, still not working. Re-installed the compiler, not working either. Changed the LCD (I was really deperate at this point) but no success. I was really pulling my hair as the simplest TX RX program didn't work. Anyhow, the important thing is that it now works. |
|
|
|
|
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
|