Author Topic: Corrupted serial port in MCU  (Read 2732 times)

0 Members and 4 Guests are viewing this topic.

Offline plancTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 149
  • Country: us
Corrupted serial port in MCU
« on: May 18, 2023, 09:59:36 pm »

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.



 

Offline Kim Christensen

  • Super Contributor
  • ***
  • Posts: 1669
  • Country: ca
Re: Corrupted serial port in MCU
« Reply #1 on: May 18, 2023, 11:28:08 pm »
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 )
« Last Edit: May 18, 2023, 11:37:37 pm by Kim Christensen »
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1816
  • Country: au
Re: Corrupted serial port in MCU
« Reply #2 on: May 19, 2023, 01:23:48 am »
I bought a used 68HC11 evaluation board. But it showed this error when a terminal software was used to access it.
Do you have a scope, to check the signal integrity ?
Also check the supply lines, in case the caps are EOL ?
 

Offline plancTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 149
  • Country: us
Re: Corrupted serial port in MCU
« Reply #3 on: May 19, 2023, 01:30:01 am »

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.
 

Offline srb1954

  • Super Contributor
  • ***
  • Posts: 1110
  • Country: nz
  • Retired Electronics Design Engineer
Re: Corrupted serial port in MCU
« Reply #4 on: May 19, 2023, 02:31:23 am »

I bought a used 68HC11 evaluation board. But it showed this error when a terminal software was used to access it.

What model/manufacturer is the evaluation board?

 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1816
  • Country: au
Re: Corrupted serial port in MCU
« Reply #5 on: May 19, 2023, 06:09:57 am »
  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?
Crystals 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'
 

Offline plancTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 149
  • Country: us
Re: Corrupted serial port in MCU
« Reply #6 on: May 19, 2023, 06:36:58 am »
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.
 

Offline wek

  • Frequent Contributor
  • **
  • Posts: 529
  • Country: sk
Re: Corrupted serial port in MCU
« Reply #7 on: May 19, 2023, 07:07:08 am »
> 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
 

Offline plancTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 149
  • Country: us
Re: Corrupted serial port in MCU
« Reply #8 on: May 19, 2023, 07:10:32 am »
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?

 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3313
  • Country: gb
Re: Corrupted serial port in MCU
« Reply #9 on: May 19, 2023, 09:12:08 am »
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.

You 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.
 

Offline srb1954

  • Super Contributor
  • ***
  • Posts: 1110
  • Country: nz
  • Retired Electronics Design Engineer
Re: Corrupted serial port in MCU
« Reply #10 on: May 19, 2023, 09:12:47 am »

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.
Start 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 the minimum pulse 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. 



 

Offline plancTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 149
  • Country: us
Re: Corrupted serial port in MCU
« Reply #11 on: May 19, 2023, 10:12:47 am »

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??

 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4662
  • Country: dk
Re: Corrupted serial port in MCU
« Reply #12 on: May 19, 2023, 11:40:04 am »
Max232 is an RS232 transceiver,  M74C14N is an inverter

I suspect the opto and diodes is an ugly hack to get sorta-kinda RS232 by stealing power from RX and control signals to do TX

It 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
 

Offline plancTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 149
  • Country: us
Re: Corrupted serial port in MCU
« Reply #13 on: May 19, 2023, 12:04:15 pm »



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?
 

Offline srb1954

  • Super Contributor
  • ***
  • Posts: 1110
  • Country: nz
  • Retired Electronics Design Engineer
Re: Corrupted serial port in MCU
« Reply #14 on: May 19, 2023, 12:24:04 pm »

Why do you mention MAX232?
Because 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.
Quote
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?
A 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.

 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4662
  • Country: dk
Re: Corrupted serial port in MCU
« Reply #15 on: May 19, 2023, 12:38:41 pm »
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
 

Online eutectique

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: be
Re: Corrupted serial port in MCU
« Reply #16 on: May 19, 2023, 01:38:00 pm »
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.
 

Offline plancTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 149
  • Country: us
Re: Corrupted serial port in MCU
« Reply #17 on: May 19, 2023, 01:55:03 pm »

Why do you mention MAX232?
Because 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.
Quote
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?
A 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.

But 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.

 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4662
  • Country: dk
Re: Corrupted serial port in MCU
« Reply #18 on: May 19, 2023, 02:41:57 pm »

Why do you mention MAX232?
Because 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.
Quote
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?
A 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.

But 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.

you 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

 

Offline Kim Christensen

  • Super Contributor
  • ***
  • Posts: 1669
  • Country: ca
Re: Corrupted serial port in MCU
« Reply #19 on: May 19, 2023, 03:23:49 pm »
Max232 is an RS232 transceiver,  M74C14N is an inverter
I suspect the opto and diodes is an ugly hack to get sorta-kinda RS232 by stealing power from RX and control signals to do TX
It 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

I 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.
« Last Edit: May 19, 2023, 04:22:51 pm by Kim Christensen »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4292
  • Country: us
Re: Corrupted serial port in MCU
« Reply #20 on: May 19, 2023, 11:07:50 pm »
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.

 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4662
  • Country: dk
Re: Corrupted serial port in MCU
« Reply #21 on: May 19, 2023, 11:46:44 pm »
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?
(Attachment Link)
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.

google turns up a lot of circuits similar to this

 

Offline plancTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 149
  • Country: us
Re: Corrupted serial port in MCU
« Reply #22 on: May 20, 2023, 10:01:38 pm »
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 TLV2211 https://www.ti.com/lit/ds/symlink/tlv2211.pdf connected 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!
« Last Edit: May 20, 2023, 10:04:57 pm by planc »
 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4662
  • Country: dk
Re: Corrupted serial port in MCU
« Reply #23 on: May 20, 2023, 10:30:55 pm »
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?

probably just used as a buffer to drive the optocoupler, because the 68HC11 can't drive the led in optocoupler hard enough
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf