Atmega168 and Atmega328 ADC sporadic

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Atmega168 and 328.
I program my Atmega328 with the option of ADC0 and ADC1. All works great as long as the chip is turned on. If I turn off the chip for more than 5 seconds. The ADC readings are sporadic. I compare the chips with the program sources, no errors? All are the same. These since I buy new chips. If the same program is put on my atmega168 dating 4 years, no problem !. When I had the problem with my 4 atmega168 of the same series. I order atmega328p and have my great suprise they do the same thing. I program under avrstudio4. I'm really discouraged. A +

 

Including my source program under Avr Studio 4 in Assembler

Attachment(s): 

This topic has a solution.
Last Edited: Tue. Apr 18, 2017 - 04:38 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If I turn off the chip for more than 5 seconds. The ADC readings are sporadic.

So do you turn the chip on again before you get the sporadic readings? surprise

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, I disconnect it for 5 minutes and then reconnect it and these the same thing. I check with the source and no error. I reprogram it, I do my ADC readings and no errors. As long as it is plug in no error.

Have you since they have been buy by MIcroChip that they have more quality control?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you applying external signals to a powered-down microcontroller?

 

Definitely a Bad Idea ...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Often times when something works when the programmer is connected, but not when the programmer is disconnected, the problem has to do with the programmer providing a Ground that is otherwise missing.

 

How do you have your analog input signals connected to the micro, and do they have a common ground with the micro?

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If the situation is:   AVR is programmed and it works OK.   It works OK as long as the power is on.  When the power is switched off for five seconds, and then the AVR is powered on, there are problems.   In the five-second power-off interval, all the residual voltage is drained from the internal circuitry.

 

This is not a hardware issue with the microcontrollers.  The difference in operation between the new and old AVRs is likely due to a different manufacturing process in the new AVRs.  The old process allows values that permit correct operation to be loaded into the peripheral control registers (or variable memory locations) by default, and the new manufacturing process causes different values to be loaded into these critical memory locations.   And the programming process is placing values into memory locations of the AVR and those values are not being put into the memory locations after a power off/on cycle.   The device programmer is initializing memory (or peripheral control registers)  to specific values that allow the program to operate correctly, but the power-on process is not initializing those memory locations to the same values.  This is a software issue that is most likely due to the memory (and peripheral control registers) not being initialized correctly.

 

First question:  Does performing a RESET\ cause the same problems that power-off (and the five second interval) causes?  Reset\ does not affect memory values (or the peripheral control registers, which are located at the beginning of the SRAM memory block).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:
Often times when something works when the programmer is connected, but not when the programmer is disconnected, the problem has to do with the programmer providing a Ground that is otherwise missing.

Could also be that the programmer is providing a good reset that is otherwise missing.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To answer DocJC, I take an LM35 which read temperature and a voltage divider to read the voltage. The LM35 is powered at the same source as the Atmega and even for the voltage divider.

To answer Simonetta, yes even I made a RESET \ with power ON, no change. I put the Atmega OFF, RESET to ground and Atmega ON. No change. I try with an external crystal always the same.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you just flash an led on a few off, once a second, does it work correctly, without the programmer attached, and after cycling the Power? Can you attach a photo of your hardware?

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Uninitialised automatic?

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Uninitialised automatic?

 Including my source program under Avr Studio 4 in Assembler

wink 

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I haven't looked at it (off to bed), but the same issue could be at work.  Programming results in all SRAM and all GP registers getting cleared to 0x00.  A reset, has no effect on SRAM or GP registers.  SRAM will power up with effectively random contents.  Only GP registers will power up as 0x00, and then only if VCC was dropped below about 0.1 volts.  If bypass caps keep Vcc above about 0.2 V, GP registers will be unaffected.

 

 

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I found the problem thanks to your valuable advice. It is the IC TCM5089 that is a DTMF encoder that is the problem. The chip is obsolete, I will find a newer one.

I thank you for the invaluable help of helping find my problem. :o)

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The TCM5089 seems to be just a DTMF encoder, maybe you can replace it with software??

 

AVR314 application note has code both in C and ASM for a 8MHz clock.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly