Dual UART problems ATTN: Gunther Daubach and anyone else
John Whitfield
Posts: 42
I have been having endless troubles with this program. The main problems are occuring on the first UART which runs at 1200 baud with seven data bits and two stop bits. I get mostly correct and wholy verifiable data out of the second UART which runs at 9600 baud. When connected to a terminal program or logic analyzer: the first UART puts out no changes on·pin RB7. It appears to be sending some kind of output on the oscilloscope, but that could be some kind of random problem, I'm not sure. It could be that I'm still not getting the hardware setup right. The device I'm using METEX M-3850D is supposed to operate as RS232C, but the realterm terminal program only recognizes the device as RS485. It is imperative that this code be completed as soon as possible, so anyone with any ideas on hardware or software please post them. I am now the only one working on this project, so the situation is dire.
-John Whitfield
-John Whitfield
src
20K
Comments
I use the attached windows program to display/log DMM values to the PC.
Please confirm your DMM·port operates correctly.
regards peter
Thanks,
-John Whitfield
doing the right RS-232 protocol on one hand means correctly sending the serial data (speed, bit count, number of stop bits, polarity, and eventualy a parity bit) but - on the other hand, it eventually also requires that a hardware handshake is handled correctly, e.g. on the RTS and CTS lines.
The SX UART code you are using does not handle any handshake. I don't know the M3850, so I can't say if it requires handshake, or not. But before taking care of that matter, you should verify that the 1200 Baud UART is sending data, and you can do this with an oscilloscope. For testing, you might use a main program loop which constantly sends out a specific character via the UART. In this loop, don't forget to test the tx_count variable being zero before preparing the UART for sending another character.
In the source code you have posted, I noticed that you invert the data bits when writing to the TX port pins. Please double-check if this is necessary. Nevertheless, using the test, described before, polarity does not matter because you should first verify if the UART is sending at all.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
I read your code and your protocol is correct.
You send 'D' to the DMM and it responds with 14 bytes, but only
if DTR is on (I tested it with a PC and terminal program).
So the DMM pin that connects to PC com port pin 4 (DB9) must
be on. So you need 4 wires from the SX to the DMM.
GND, RX, TX, DTR
I did not find in your code that you turn on DTR.
regards peter
regards peter
·
DTR must be on and RTS must be off!
Here is the M3850 cable layout
DMM pins
o o o·· o o
| | |··· | |······ DB25F· DB9F· name(PC)
| | |··· | +----··· 3······ 2······· RX········ output from DMM
| | |··· +
·· 20······4······ DTR······· input to DMM
| | +
··· 4····· 7······ RTS········input to DMM
| +
··· 2······ 3········TX········ input to DMM
+
·· 7······· 5······ GND
If you use a MAX232 you can tap the DTR signal from MAX232 pin 6 (V-)
and RTS signal from MAX232 pin 2 (V+)
(I believe V- is on and V+ is off, If nothing happens, swap these)
regards peter
·
Thanks,
-John
-John Whitfield