Atmega16 laggy, slowed down - Page 1
Forum section: electronics / general

author: VeryFastSnail
author_rank: Contributor
timestamp: December 17, 2019, 07:58:25 am
content: Hello members!I have this question about atmega16:Can this chip somehow change it’s clock speed on power surge?Because I just had and accodent when mu equipement (that uses this mcu) became unberably slow, I mean it had slowed down in every task that it’s responsible to, from booting, to controlling pwm signal as I guess because every action that this chip must providebis now slower.This happened when I was powering it off with simple switch (and I guess it got power surge or sometging)Another tging I have thought of is reset line issues, maybe it’s to blame? Noise signal ect.Is it possible to read fuses from locked chip? Because I almost am sure that it is lockedBut right now I cant check it because I have no isp programmer

author: Jeroen3
author_rank: Super Contributor
timestamp: December 17, 2019, 08:18:05 am
content: The fuses are not supposed to be programmed by itself.Are you sure you're not looking at a noisy external interrupt?

author: VeryFastSnail
author_rank: Contributor
timestamp: December 17, 2019, 08:47:08 am
content: Very interesting obsorvation... neverbwould thought about it. So it may be to blame because interups cause main loop to stop, right? So how could it fail after power disconnection? Maybe some components failed?

author: ebclr
author_rank: Super Contributor
timestamp: December 17, 2019, 07:20:28 pm
content: Try changing the 16 Mhz crystal

author: VeryFastSnail
author_rank: Contributor
timestamp: December 17, 2019, 08:08:25 pm
content: Quote from: ebclr on December 17, 2019, 07:20:28 pmThere are pads pn pcb for crystal, but mcu uses integrated resonated 8mhz witch is 1mhz after division... If oscilator would be toast, it would not work. And how could we explain that it just became like that after quick restart.

author: VeryFastSnail
author_rank: Contributor
timestamp: December 17, 2019, 08:14:52 pm
content: Yet another question is how to know what kind of frequancy it’s running, because as I know it can be configured to run at 1mhz, 8mhz, 16mhz ect... mayne some pins provide clock that I could measure with oscilloscope?

author: VeryFastSnail
author_rank: Contributor
timestamp: December 19, 2019, 07:40:29 pm
content: Found that interupt1 is always high, could that be the problem? It’s always 5volts

author: cv007
author_rank: Frequent Contributor
timestamp: December 19, 2019, 10:00:30 pm
content: The avr executes one instruction after global interrupts are enabled. In an ISR, the final reti instruction enables the global interrupt and you get at least one instruction executed. If there is a faulty interrupt going on where an interrupt is always on (and there is an isr for it), then other code still runs but will be running at a ratio of 1:#of clocks in isr. An example would be a level interrupt (low), where the intN pin remains low (and setup for irq). Another would be a tx isr that is never disabled when there is no more data to send, or an eeprom ready irq that is not disabled. There may be others, but most interrupts on this avr will clear the flag and would be difficult to get constant/repeated firings.It would be quite odd to get to that point though, so the above is just info you can put in the back of your mind.

author: VeryFastSnail
author_rank: Contributor
timestamp: December 30, 2019, 10:02:26 am
content: Well, so what could be the issue? If I read fuses via ISP, can I change clock settings on locked chip?

author: JustMeHere
author_rank: Frequent Contributor
timestamp: January 02, 2020, 12:36:41 am
content: I'm fairly sure you can unlock the chip with a full erase. You can set the clock out fuse and read the pin with an oscilloscope.Make sure setting your clock rate correctly in your code.

author: coldfiremc
author_rank: Regular Contributor
timestamp: January 02, 2020, 02:49:47 am
content: This can be caused by a noisy clock or some "not square" signal on an Interrupt line/pin. Check the clock waveform (is not square or sine, but must be monotonic in its transition) ans check that there's no strange noises in pins. Also a non square waveform in a digital pin causes metastability, and can make internal synchronizers struggle to get the proper signal.

author: VeryFastSnail
author_rank: Contributor
timestamp: January 04, 2020, 10:40:10 pm
content: Quote from: coldfiremc on January 02, 2020, 02:49:47 amThis issue happened when I was powering unit down, after quick power on, it started to act like that, the issue is that I do not have firmware for that product, so if I erase all chip content, I'm screwed...MCU still functions fine, but slow as hell, there are no strange not square signals, checked it with my oscilloscope.Problem is that it uses internal clock, and I can't measure internal clock with my oscilloscope... or I don't know how to...

author: VeryFastSnail
author_rank: Contributor
timestamp: January 04, 2020, 10:41:12 pm
content: Quote from: JustMeHere on January 02, 2020, 12:36:41 amI can't erase chip, that would kill my equipment...

author: VeryFastSnail
author_rank: Contributor
timestamp: January 04, 2020, 10:56:03 pm
content: This is quick 861DW mother board, it's quite simple board consist of atmega16a. I attached some images of main boardP.S board has external pads for crystal. those are connected to XTAL1 and XTAL2 of mcu, but no signal on XTAL2, chip uses integrated clock (as I suspect)

author: cv007
author_rank: Frequent Contributor
timestamp: January 05, 2020, 12:30:44 pm
content: >MCU still functions fine, but slow as hellI would measure the INT0/INT1 pins just to see if either is always low (pin 11,12). Let's say they are using int0 or int1 in a level interrupt, and they never planned for the case where the low level remains always low. Maybe connected to a switch gone bad, maybe something else, but if there was a continuous low level on either pin, AND they were using it as an ext interrupt, AND some fault caused the pin to remain low, AND they never allowed for the possibility, the mcu still goes about its business but will be slow like I described previously. If the int0/1 isr was simple, I imagine you would be at least 20 times slower than normal.If one of those pins was always low, you could simply desolder/lift a pad to see what happens. If that helps, then you can trace the pin to find out what is attached and causing the abnormal low level.Quite a long shot, but probably as good as any, and it will take 5 minutes to check out.

author: VeryFastSnail
author_rank: Contributor
timestamp: January 05, 2020, 10:40:06 pm
content: Quote from: cv007 on January 05, 2020, 12:30:44 pmSee image attached.I have lifted all three INT pins and nothing changed.This is what I observed. INT2 (PB2 in pinout) is used for screen controlling, so after lifting it up, screen kept blank. (no communication between micro and screen)other two has something connected to them. INT1 has a resistor and capacitor connected in parallel and pin INT0 has 5 v on it but goes to non populated area of the board. (I had cut trace before you can see in picture. Actually I cut two, but nothing changed.)So maybe this is not interrupt issue?This could be internal problem of mcu. I would easily change it, but firmware is the problem... I do not have it. I contacted Quick associates, and they replied, I asked for firmware and/or new board, they asked for video proof, I did it. waiting for their response.P.S I would imagine that whole firmware code for this station is under 500 lines. It has simply to control air speed (there is external pcb for that) and heep heater powered periodically, read temperature and ajust, drive display and that it... :/ would love to write my own for it, but have no time right now..

author: coldfiremc
author_rank: Regular Contributor
timestamp: January 07, 2020, 02:53:50 pm
content: If you touch fuses, some fuse can redirect clock to the outer world in some pin of the output port B, maybe pin 2 (I don't remember at this time, but is possible).

author: 2N3055
author_rank: Super Contributor
timestamp: January 07, 2020, 06:45:31 pm
content: If fuses got scrambled, it could have reverted to internal RC oscillator at 1MHz...The fact that you don't see signal on quartz points to that possibility.Did you try reading fuses with the programmer?

author: VeryFastSnail
author_rank: Contributor
timestamp: January 08, 2020, 01:07:08 pm
content: Quote from: 2N3055 on January 07, 2020, 06:45:31 pmI did, but as for now I cant seem to connect to it. Maybe because of slowed down clock?

author: VeryFastSnail
author_rank: Contributor
timestamp: January 08, 2020, 01:07:46 pm
content: Quote from: coldfiremc on January 07, 2020, 02:53:50 pmI know that, but can I edit fuses eithout erasing protected chip?

author: VeryFastSnail
author_rank: Contributor
timestamp: January 08, 2020, 01:13:58 pm
content: UPDATE: quick team will provode me with another mainboard free of charge.But I still want to know what could be the problem... this happed when I was powering station down and then immidiatelly back on, i suspect voltage jump at sense pin of mcu for temperature control.Could bad/failing amp cause this?