Corrupted serial port in MCU - Page 1
Forum section: electronics / general

author: planc
author_rank: Regular Contributor
timestamp: May 18, 2023, 09:59:36 pm
content: I bought a used 68HC11 evaluation board. But it showed this error when a terminal software was used to access it.The following shows what the terminal should appear. After the Buffalo line get displayed, and you press enter. The commands should display and repeat if you press enter over and over. In the case of the corrupted serial display above. It's like the whole commands fit into one line with garbage.This is the circuit and image I found in the net how the serial port of the HC11 is accessed. The left of the MCU is the clock. The one at bottom is the serial port. I replaced the MCU and even the M74C14N to another PCB and they are completely working, so the problem is in the resistor or diode (the white H11A1 is the optoisolator). Why is there diodes in the serial port? Maybe one of them is defective? What you think is the defect based on the corrupted serial display? Thanks.

author: Kim Christensen
author_rank: Super Contributor
timestamp: May 18, 2023, 11:28:08 pm
content: Is the RS232 signal ground OK? ( I see that you've got a schematic for a DB9 but the PCB has a DB25... Ground is pin5 on the DB9 but it is pin 7 on the DB25 )

author: PCB.Wiz
author_rank: Super Contributor
timestamp: May 19, 2023, 01:23:48 am
content: Quote from: planc on May 18, 2023, 09:59:36 pmDo you have a scope, to check the signal integrity ?Also check the supply lines, in case the caps are EOL ?

author: planc
author_rank: Regular Contributor
timestamp: May 19, 2023, 01:30:01 am
content: What kind of oscilloscope minimum to get just to trace it? Where to put the trace? How can you be sure the problem is not in the MCU clock crystal? What kind of error if it is a clock error instead of serial port?I'll check the ground but it is clean.

author: srb1954
author_rank: Super Contributor
timestamp: May 19, 2023, 02:31:23 am
content: Quote from: planc on May 18, 2023, 09:59:36 pmWhat model/manufacturer is the evaluation board?

author: PCB.Wiz
author_rank: Super Contributor
timestamp: May 19, 2023, 06:09:57 am
content: Quote from: planc on May 19, 2023, 01:30:01 amCrystals tend not to fail slightly.It does not look like a baud error, as it does not favour bits away from the start bit.It's easy to check tho, as most USB-UARTS allow fine settings for baud like 24M/N or 12M/N, some are even better.You will need a scope to check that baud it actually applied.On an old board, I'd suspect bad caps, and maybe partly corrupt ROM, but it's 'almost working'

author: planc
author_rank: Regular Contributor
timestamp: May 19, 2023, 06:36:58 am
content: It's a private company that uses the HC11 evaluation chip with Buffalo to avoid starting from scratch.Where is the rom located? I have transferred the HC11 chip and even the M74C14N to another board and they were working.How do I know which capacitor? Can I test the capacitor in assembled unit? I can't remove them one by one.

author: wek
author_rank: Frequent Contributor
timestamp: May 19, 2023, 07:07:08 am
content: > I'll check the ground but it is clean.I visualized a freshly wiped floor... :-)A broken ground wire in calbe, or faulty ground pin in connector, can make wonders.JW

author: planc
author_rank: Regular Contributor
timestamp: May 19, 2023, 07:10:32 am
content: Also why do you say it's USB-UARTS? It has no USB. It is old RS-232 although I use a USB-Serial port converter to run it. How do I use fine tuning and what is 24M/N or 12M/N? what's M/N? Thanks.Could the H11A1 be defective? Is there a separate circuit I can buy that can make me just tap to the RxD and TxD of the MCU to make it run?

author: mikerj
author_rank: Super Contributor
timestamp: May 19, 2023, 09:12:08 am
content: Quote from: planc on May 19, 2023, 07:10:32 amYou answered your own question, you are using a "USB UART" at the PC end so you may be able to fine tune the baud rate. However as PCB.Wiz said, this doesn't look like a baud rate problem. An oscilloscope is invaluable for diagnosing these kinds of problem, even one of the toy oscilloscopes would likely be adequate.

author: srb1954
author_rank: Super Contributor
timestamp: May 19, 2023, 09:12:47 am
content: Quote from: planc on May 19, 2023, 01:30:01 amStart by scoping the RS232 signals on the DB9 connector.The TXD signal should swing from a level below -5V to a level above +5V. If the signal swing is less than those levels check again without the serial cable connected. If it is still less than the required levels you need to check the voltage levels on pins 2 and 6 of the MAX232. The voltages should be around +10V and -10V respectively. If not check the supply voltage on pin 16 of the MAX232 is in the range 4.75 - 5.25V. If the supply voltage is OK and clean without ripple then the capacitors around the MAX232 need replacing. If that doesn't restore the correct levels then the MAX232 needs replacing.If all the levels are OK then the signal timing needs to be checked. Assuming it is a standard BUFFALO monitor configuration at 9600 Baud theminimumpulse width on the TxD line should be around 104us. If the minimum pulse width differs significantly from 104us then check the driver input at pin 10 of the MAX232. It should swing less than 0.4V and greater than 2.4V with clean transitions, no noise and have the specified timing. If the signal levels are OK but the timing is wrong you need to check that the 68HC11 is operating at the right frequency.Again, assuming that it is a standard BUFFALO monitor configuration with an 8MHz crystal, the E clock on pin 5 of the processor chip should be at 2MHz or very close. Then E clock should swing from nearly 0V to nearly 5V with clean transitions and no noise. If those conditions are not meet then the 68HC11 and/or the crystal needs to be replaced.

author: planc
author_rank: Regular Contributor
timestamp: May 19, 2023, 10:12:47 am
content: Why do you mention MAX232? It's just example of schematic I saw of how the serial is connected to the HC11. The actual chip used as shown in original pcb image in message 1 is M74C14N. Is Max232 and M74C14N identical?I'm sure it's not the 68HC11 because I extracted the chip and replace another working one and the same problem. Even replace the M74C14N and the same garbage. I'm thinking if it's the H11A1 optoisolator.I tried to trace the ground at Pin7 of the DB25 and here is what I found out.The ground at Pin7 of the DB25 is connected to Pin2 of the Optoisolator H11C1. While Pin1 is connected to the resistor at left and zener at right (shown with violet paths in pcb photo above). And the top of the Zener are connected to Pin 2 of the DB25 which is TRANSMIT DATA.How does the H11C1 isolation work? Why is DB25 pin7 ground connected to pin 2 of the H11C1 and the pin1 is connected with the resistor and zener to the TRANSMIT DATA pin2 of the DB25??

author: langwadt
author_rank: Super Contributor
timestamp: May 19, 2023, 11:40:04 am
content: Max232 is an RS232 transceiver, M74C14N is an inverterI suspect the opto and diodes is an ugly hack to get sorta-kinda RS232 by stealing power from RX and control signals to do TXIt might rely on the control pins to be set in certain way and it may not work at all with a "modern" USB-RS232 interface that barely meets RS232 specs

author: planc
author_rank: Regular Contributor
timestamp: May 19, 2023, 12:04:15 pm
content: I have 2 units of it. It's an EEG with 2 channel amplifiers that feeds into the MCU and displays at PC. I'm studying amplifer quality and noise reduction. The bottom unit is earlier prototype and the serial port is working when I used a usb-serial cable with driver USB-Serial CH340. I can access it all the time. I bought the top unit just last week. I couldn't get it to run with the serial garbage output. I swapped the 68HC11 chips and M74C14N yesterday, and the bottom still worked. And the top unit still has same garbage. It means the 68HC11 chip and M74C14N is perfectly working.Why do you think there is the inverter M74C14N there? What is the purpose? The purpose of the optoisolator is to avoid getting shock in the head from serial cable when you connect the EEG electrodes. They are entirely powered by batteries. The diodes have no purpose than a hack?

author: srb1954
author_rank: Super Contributor
timestamp: May 19, 2023, 12:24:04 pm
content: Quote from: planc on May 19, 2023, 10:12:47 amBecause you showed a schematic of it. I assumed you were trying to use a MAX232 to connect from your EV board to your external device. It would have helped if you had supplied a schematic of the circuit you are actually using.QuoteA 74HC14 is a completely different chip to the MAX232, which is specifically designed to interface RS232 systems. A 74HC14 is just a standard hex Schmitt trigger inverter logic chip, nothing at all to do with RS232 interfaces.If the circuit you are using is based on the H11A1 opto-couplers then it would only be producing a poor approximation to a real RS232 circuit and is unlikely to inter-work reliably with any proper RS232 devices. I suggest you junk the existing circuit completely and replace with a MAX232 or similar.You can buy RS232-TTL interface PCBs which contain a MAX232 (or similar) chip, its ancillary components and a DB9 connector, for a a few dollars. These connect directly to the microprocessor serial port and convert its TTL level logic signals to proper RS232 levels compatible with any proper RS232 interface. Make sure you get one that uses a 5V supply for compatibility with the 68HC11 microprocessor signal levels.

author: langwadt
author_rank: Super Contributor
timestamp: May 19, 2023, 12:38:41 pm
content: there is no power pin in RS232 so get power for the TX the diodes are used to steal power from RX, with a cheaply made USB-RS232 converter that might be marginal, and not work reliably

author: eutectique
author_rank: Frequent Contributor
timestamp: May 19, 2023, 01:38:00 pm
content: FYI, revision D of CME-11E9 evaluation board has MAX232 converter and DB9 serial connector. You would be better off going this path, as already suggested.

author: planc
author_rank: Regular Contributor
timestamp: May 19, 2023, 01:55:03 pm
content: Quote from: srb1954 on May 19, 2023, 12:24:04 pmBut how do you add an optoisolator between the Max232 and the MCU and circuit? The purpose of optoisolator is to prevent electrical shock or leakage from the RS232 port from reaching the electrodes connected to the brain of the user.

author: langwadt
author_rank: Super Contributor
timestamp: May 19, 2023, 02:41:57 pm
content: Quote from: planc on May 19, 2023, 01:55:03 pmyou either get a different USB-RS232 and hope it works better, or you start over with two optos and a USB-TTL uart adapter with 5V

author: Kim Christensen
author_rank: Super Contributor
timestamp: May 19, 2023, 03:23:49 pm
content: Quote from: langwadt on May 19, 2023, 11:40:04 amI suspect this is the problem. A lot of those USB-RS232 adapters don't output more than +-5V, which while in spec, is not enough to work with this circuit reliably. I bet if the OP was using a RS232 adapter that outputted +-9V or more, it would work perfectly.planc: Measure the voltages on the ends of the diodes that attach to the DB25/RS232 port when the circuit is powered but not sending data. If the voltages are low (around +-5V or less) then that is likely your problem.One PCB working vs the other not working may be due to the current transfer ratio of the H11A1 on the working board being higher than on the failing one. They spec the minimum CTR of the H11A1 as 50% so the non working one could be 51% while the working one is 60%... Both OPTOs would be in spec and working, but because of the marginal design and using a USB-232 adapter, it doesn't always work.

author: westfw
author_rank: Super Contributor
timestamp: May 19, 2023, 11:07:50 pm
content: From OP, this is a very weird-looking circuit for "rs232" - are you sure it's not doing something more custom, that just happens to use a DB25 connector?The diodes and optos make it look like it MIGHT be some sort of line-powered, isolated, discrete rs232 implementation that might be dependent on being able to suck power from the db25 modem control signals. Those signals may not be present on a modern usb/rs232 cable, or may have insufficient voltage to drive this circuit.

author: langwadt
author_rank: Super Contributor
timestamp: May 19, 2023, 11:46:44 pm
content: Quote from: westfw on May 19, 2023, 11:07:50 pmgoogle turns up a lot of circuits similar to this

author: planc
author_rank: Regular Contributor
timestamp: May 20, 2023, 10:01:38 pm
content: I used another USB-Serial converter (a KeySpan brand) and it worked perfectly! There is no longer garbage. So you guys are right about the diodes thing stealing power from the RX. But what is the purpose of the inverter 74HC14? It is right between the H11A1 optocoupler and the 68HC11 MCU serial transmit and receive pin?Now I can finally focus on the amplifier part. The old unit used AD620 while the new unit used LT1168 amplifier. I finally ran the new one and there is less noise indeed, for example, it can't cause interference from 60Hz AC line.The old unit has amplifier input impedance of 10 Gohm and CMRR of 100 dB. While the new unit has amplifier input impedance of 1000 Gohm and 120 dB. It claims the "input noise and interference is reduced overall by a factor of more than 1000". How do you compute the 1000 factor in dB from 100 to 120 dB?These units were made in the early 2000. The final design they offer (which I also owned) were based on the op-amp TLV2211https://www.ti.com/lit/ds/symlink/tlv2211.pdfconnected to 24 bit ADC ADS1254 with serial digital output and into the MSP430 MCU. But the spec of this final design is still 1000 Gohm and 120 dB.Is there no op-amp with spec above 1000 Gohm and CMRR above 120 dB? Why?Also i plan to use a test input signal that can produce 5 uV sine wave (or any microvolt signal) and inject this into the 2 input and ground of the 3 units and check the output at PC and compare the noises. What test input signal device can I use??Thanks!

author: langwadt
author_rank: Super Contributor
timestamp: May 20, 2023, 10:30:55 pm
content: Quote from: planc on May 20, 2023, 10:01:38 pmprobably just used as a buffer to drive the optocoupler, because the 68HC11 can't drive the led in optocoupler hard enough