AVR locks up sporadically after being connected to a comm bus - Page 1
Forum section: electronics / general

author: Artlav
author_rank: Frequent Contributor
timestamp: August 07, 2019, 01:32:12 pm
content: So i had a thing controlled by an atmega328p which worked for years without any problems.Then i decided to connect it to a custom single wire UART bus (open drain), and found it sporadically locking up.Like, once a week.I can't figure out what could be causing this.Doubt it's firmware related - the communications are interrupt driven and lack any loops.The implementation is bit banged, so it's not some Atmel silicon weirdness.That leaves something electrical as the source.The bus does sprawl for dozens of meters and coexist with/cross all sorts of wiring.The connection to the micro is as below, a protection resistor in series. With the chip itself having clamp diodes rated to 1mA continuous, this should be taking care of any voltage spikes on the bus.The lock up is pretty much total unresponsiveness to anything, with all the pins stuck in whatever states they were in at the moment.What am i missing?

author: Psi
author_rank: Super Contributor
timestamp: August 07, 2019, 02:11:29 pm
content: I think your series resistor + the internal clamp diodes isn't enough to protect the input when you have multiple meters of external cabling to other devicesI had a similar lockup problem with an AVR a month back.I was feeding analog data into ATMega ADC input and occasionally it would lockup.The problem turned out to be an occasional pulse on the data line that was above 5V.I put external clamp diodes to GND and VCC and added a series resistor after that.Never had it crash again after that.

author: mikerj
author_rank: Super Contributor
timestamp: August 07, 2019, 05:39:24 pm
content: Quote from: Artlav on August 07, 2019, 01:32:12 pmWhere is the ESD diode current specified? If those diodes are conducting, you are almost certainly exceeding the absolute maximum pin voltage specification.

author: floobydust
author_rank: Super Contributor
timestamp: August 07, 2019, 07:51:15 pm
content: Quote from: Artlav on August 07, 2019, 01:32:12 pmThis is incorrect, in the real world you are over 1mA at >4.3V on the bus.The problem with using the MCU internal clamp-diodes and a current-limiting resistor is IF the bus sees greater than 3.8V, say you have a 12V blip at INP-1, it will kick up VCC way past 3.3V. A LDO voltage regulator IC cannot sink current. ATtiny uses only a few milliamps and 510R is not a high enough value to stop injection current from raising VCC (powering) the MCU.You would need a much larger resistor or TVS at the signal pin, or both. Plug a connector on crooked and INP-1 could see 12V.

author: ogden
author_rank: Super Contributor
timestamp: August 07, 2019, 08:33:03 pm
content: Quote from: floobydust on August 07, 2019, 07:51:15 pmResistor is fine. TVS needed. Add 3.3V TVS protection diode like SMLVT3V3 and you are done solving your issue.

author: Artlav
author_rank: Frequent Contributor
timestamp: August 12, 2019, 11:20:00 pm
content: Ok, so i added a TVS, SMLVT3V3, and it started to work kinda flakey but acceptable.A few days later it occurred to me to investigate what is going on, and i soon noticed the 5200pF capacitance this TVS carries.That's almost enough to smooth the bit transitions on the bus below the high/low threshold, which is why it was kinda flakey.So, what should i be looking for besides the reverse standoff voltage?Would CDSOD323-T03 do the job?

author: ogden
author_rank: Super Contributor
timestamp: August 13, 2019, 07:08:50 am
content: Quote from: Artlav on August 12, 2019, 11:20:00 pmOuch I missed that during quick search. Did not know that TVS data line diodes with such a high capacitance even exist! My bad.QuoteSeems like fine choice - if capacitance is ok for you. Selecting diodes always pay attention not only to capacitance, but leakage current at high voltage of your data bus - especially if it is multidrop.

author: Artlav
author_rank: Frequent Contributor
timestamp: September 26, 2019, 11:25:48 pm
content: Follow-up, a month and a half later: I've added a TVS as suggested - everything works fine since then, not a single lock-up.Thanks all!