Reply by Edson L. Bestvina October 1, 20042004-10-01
Dowload in the "Atmel-HP" the document -> AVR180: External Brown-Out
Protection Application Note
Read this item:

Prevents Non-volatile Memory Corruption

Non-volatile memories like EPROM, EEPROM, and Flash are designed to keep
their contents even when power is completely removed from the system. By the
use of a Detector to keep the MCU in Reset, all activity on the control
lines cease. The memory contents are such prevented from unintentional
writes from the CPU for the duration of the Reset. Without a Detector,
random CPU activity such as described in the introduction may initialize an
unintended write to the non-volatile memory. This may cause random
corruption of the memory contents.

Notes: 1. As the AVR CPU is not capable of writing to its own program
memory, the internal Flash Program memory contents are never affected by a
power failure situation.

2. For any write to non-volatile memory, a minimum voltage is required to
successfully write the new values into the memory. If supplied voltage at
any time during the write

cycle drops below the minimum voltage, the write will fail, corrupting the
location written to.

3. In some AVR devices, when the reset activates during a write to the
internal EEPROM, the EEPROM Address Register will be set to zero (0x000).
The result may be seen as corruption of both the location being written, and
of location zero (0x000).
Why this text is small? I dont know? And you?

I was not that I wrote this document...
Regards,

Edson

-----Mensagem original-----
De: Don Kinzer [mailto:dkinzer@dkin...]
Enviada em: sexta-feira, 1 de outubro de 2004 12:19
Para: avrclub@avrc...
Assunto: Never use the address "00" of eeprom Re: [AVR club] Re: Saving in
EEPROM without corruption? --- In avrclub@avrc..., Eric <erichards@c...> wrote:
> Why?

See this message
HYPERLINK
"http://www.avrfreaks.net/phpBB2/viewtopic.php?t 945"http://www.avrfreaks.
net/phpBB2/viewtopic.php?t 945

HYPERLINK
"http://us.ard.yahoo.com/SIG93iud4a/M)4855.5468653.6549235.3001176/D=gr
oups/S06554205:HM/EXP96730359/A#76776/R=0/SIGldm1jvc/*http://prom
otions.yahoo.com/ydomains2004/index.html" \nclick here
HYPERLINK
"http://us.adserver.yahoo.com/l?M)4855.5468653.6549235.3001176/D=groups/S=
:HM/A#76776/rand2697971" _____

"Yahoo! Terms of Service.
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.771 / Virus Database: 518 - Release Date: 28/9/2004
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.771 / Virus Database: 518 - Release Date: 28/9/2004


Reply by Don Kinzer October 1, 20042004-10-01
--- In avrclub@avrc..., Eric <erichards@c...> wrote:
> Why?

See this message
http://www.avrfreaks.net/phpBB2/viewtopic.php?t 945


Reply by Andrew Lim September 26, 20042004-09-26
Hi Joseph, I think this method will help. I will try on it. Thanks a lot !!

Andrew

joseph torelli <joetorelli@joet...> wrote:
We have various sensors ( level, temp, pressure,... ) that output 4-20ma.
We put a 250ohm 1% resistor across the sensor output. This gives 0v for
0ma and 5v for 20ma. We connect 1 side of the resistor to the analog pin
of a Atmega128. We scale the input in the AVR to show gal, deg, lbs.
We get 203 counts for 4 ma and 1023 count for 20ma.

Hope this helps.

JoeT

-----Original Message-----
From: Andrew Lim [mailto:normaxcite@norm...]
Sent: Wednesday, September 22, 2004 9:07 PM
To: avrclub@avrc...
Subject: [AVR club] Converting current to PWM

Hi everyone,

I'm trying to convert a 4-20mA current into PWM. One of the way that I
know is to have voltage input into the uP and convert it into PWM but how to
convert current to PWM?
Please help.... Thanks. Regards,

Andrew
---------------------------------
Yahoo! Groups Links

---------------------------------
Yahoo! Groups Links

To
---------------------------------


Reply by Edson L. Bestvina September 23, 20042004-09-23
Dave

Why? I dont now, but in this case that is an extreme procedure... the
intention is only solve the problem...

Look the text in ATMega8 hardware manual (page 17):
Preventing EEPROM Corruption

During periods of low VCC, the EEPROM data can be corrupted because the
supply voltage is too low for the CPU and the EEPROM to operate properly.
These issues are the same as for board level systems using EEPROM, and the
same design solutions should be applied. An EEPROM data corruption can be
caused by two situations when the voltage is too low. First, a regular write
sequence to the EEPROM requires a minimum voltage to operate correctly.
Second, the CPU itself can execute instructions incorrectly, if the supply
voltage is too low. EEPROM data corruption can easily be avoided by
following this design recommendation: Keep the AVR RESET active (low) during
periods of insufficient power supply voltage. This can be done by enabling
the internal Brown-out Detector (BOD). If the detection level of the
internal BOD does not match the needed detection level, an external low VCC
Reset Protection circuit can be used. If a reset occurs while a write
operation is in progress, the write operation will be completed provided
that the power supply voltage is sufficient. The I/O space definition of the
ATmega8 is shown in on page 257. All ATmega8 I/Os and peripherals are
placed in the I/O space. The I/O locations are accessed by the IN and OUT
instructions, transferring data between the 32 general purpose working
registers and the I/O space. I/O Registers within the address range 0x00 -
0x1F are directly bit-accessible using the SBI and CBI instructions. In
these registers, the value of single bits can be checked by using the SBIS
and SBIC instructions. Refer to the instruction set section for more
details. When using the I/O specific commands IN and OUT, the I/O addresses
0x00 - 0x3F must be used. When addressing I/O Registers as data space using
LD and ST instructions, 0x20 must be added to these addresses. For
compatibility with future devices, reserved bits should be written to zero
if accessed. Reserved I/O memory addresses should never be written. Some of
the Status Flags are cleared by writing a logical one to them. Note that the
CBI and SBI instructions will operate on all bits in the I/O Register,
writing a one back into any flag read as set, thus clearing the flag. The
CBI and SBI instructions work with registers 0x00 to 0x1F only. The I/O and
peripherals control registers are explained in later sections.

The problem exists and is recognized for the Atmel... then... in the
doubt...

Regard,

Edson
-----Mensagem original-----
De: Dave VanHorn [mailto:dvanhorn@dvan...]
Enviada em: quinta-feira, 23 de setembro de 2004 13:58
Para: avrclub@avrc...
Assunto: Re: RES: [AVR club] Re: Saving in EEPROM without corruption?
>
>I forgot... you calling "write e2prom" with enabled interrupts? That is
very
>dangerous... You do not have to use this form... disable any interrupts
>before written eeprom:
>
> cli ; disable any interrupts
> rcall write_eeprom ; call routine
> sei ; enable interrupts

Why would having ints during an EE write be dangerous?
Assuming, of course no bugs. ---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.767 / Virus Database: 514 - Release Date: 21/9/2004


Reply by Dave VanHorn September 23, 20042004-09-23

>
>I forgot... you calling "write e2prom" with enabled interrupts? That is very
>dangerous... You do not have to use this form... disable any interrupts
>before written eeprom:
>
> cli ; disable any interrupts
> rcall write_eeprom ; call routine
> sei ; enable interrupts

Why would having ints during an EE write be dangerous?
Assuming, of course no bugs.


Reply by Edson L. Bestvina September 23, 20042004-09-23
Mark The problem with external Brown out it is the "reply" speed... before the
reset is applied the microcontroller already can have damaged the content of
eeprom...

I forgot... you calling "write e2prom" with enabled interrupts? That is very
dangerous... You do not have to use this form... disable any interrupts
before written eeprom:

cli ; disable any interrupts
rcall write_eeprom ; call routine
sei ; enable interrupts Edson

-----Mensagem original-----
De: ary ardianto [mailto:aryardianto@arya...]
Enviada em: quinta-feira, 23 de setembro de 2004 11:32
Para: avrclub@avrc...
Assunto: Re: [AVR club] Re: Saving in EEPROM without corruption? use reset IC such as MAX 701 to saving the eeprom's data

"Edson L. Bestvina" <edson_bestvina@edso...> wrote:--- In
avrclub@avrc..., "Mark Jordan" <mark@c...> wrote:

Mark

My suggestion is: "Never use the address "00" of eeprom".

Edson >
> I have a circuit using an AT90S2313 working on a very noisy
> environment and subject to program 'crashes' sometimes.
> The Watchdog is very efficient recovering from crashes, but
> I'm having a corruption on the EEPROM contents.
> What is the best method of saving some bytes (2) in the
internal
> EEPROM and getting them back without corruption? Is there some sort
> of FEC applied to memories?
>
> Thanks,
> Mark Jordan


---------------------------------
"Yahoo! Terms of Service.
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.767 / Virus Database: 514 - Release Date: 21/9/2004
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.767 / Virus Database: 514 - Release Date: 21/9/2004


Reply by Dave VanHorn September 23, 20042004-09-23
At 10:53 AM 9/23/2004, Eric wrote: >Why?

The idea is that you leave the EEAR set to 00 whenever you're not using it, so an accidental write will go to 00. Of course location 00 is then not safe for data.


Reply by Eric September 23, 20042004-09-23
Why? ----- Original Message -----
From: "Edson L. Bestvina" <edson_bestvina@edso...>
To: <avrclub@avrc...>
Sent: Friday, September 24, 2004 12:06 AM
Subject: [AVR club] Re: Saving in EEPROM without corruption? --- In avrclub@avrc..., "Mark Jordan" <mark@c...> wrote:

Mark

My suggestion is: "Never use the address "00" of eeprom".

Edson

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.768 / Virus Database: 515 - Release Date: 22-Sep-04



Reply by ary ardianto September 23, 20042004-09-23
use reset IC such as MAX 701 to saving the eeprom's data

"Edson L. Bestvina" <edson_bestvina@edso...> wrote:--- In avrclub@avrc..., "Mark Jordan" <mark@c...> wrote:

Mark

My suggestion is: "Never use the address "00" of eeprom".

Edson >
> I have a circuit using an AT90S2313 working on a very noisy
> environment and subject to program 'crashes' sometimes.
> The Watchdog is very efficient recovering from crashes, but
> I'm having a corruption on the EEPROM contents.
> What is the best method of saving some bytes (2) in the
internal
> EEPROM and getting them back without corruption? Is there some sort
> of FEC applied to memories?
>
> Thanks,
> Mark Jordan


---------------------------------
Yahoo! Groups Links

To

---------------------------------


Reply by Edson L. Bestvina September 23, 20042004-09-23
Mark

Sorry, but my english is very basic...
I never had this problem with internal eeprom... only with external eeprom
(24C02).
The problem was that: if power of the circuit falls (battery) the PIC16C54
continued operating in 1,5V, but as eeprom does not operate with this
tension, all writing from this moment has left wrong...

Solution: I inserted a control of POWER of the PIC with a comparator
(LM324), I know that it does not serve for you...

Then by software...

Usually I write the routines in assembler, the "wait time" that is very
important (Wre2p_Loop):

;----------------------------
; Rotina: Escrita na E2PROM
; Parametros: End.-> Address, Data WR -> Dado
;----------------------------

Wr_e2p:

sbic EECR,EEWE ; teste EEWE ainda setado?
rjmp Wr_e2p ; entao aguarde
out EEAR,Address ; endereco
out EEDR,Dado ; dado
ldi RWork2,6
out EECR,RWork2 ; habilito E2P escrita
sbi EECR,EEMWE
sbi EECR,EEWE

Wre2p_Loop:

wdr
nop
sbic EECR,EEWE ; teste EEWE ainda setado?
rjmp Wre2p_Loop ; entao aguarde

ret

;----------------------------
; Rotina: Leitura da E2PROM
; Grava sequencial a memoria E2p de 00h ate 09h
; Parametros: End.-> RWork1, Data (retorno) -> Dado
;----------------------------

Rd_e2p:

sbic EECR,EEWE ;if EEWE not clear
rjmp Rd_e2p ; wait more
out EEAR,Address ;output address
sbi EECR,EERE ;set EEPROM Read strobe
in Dado,EEDR ;get data

ret Regards

Edson -----Mensagem original-----
De: Mark Jordan [mailto:mark@mark...]
Enviada em: quinta-feira, 23 de setembro de 2004 08:32
Para: avrclub@avrc...
Assunto: Re: [AVR club] Re: Saving in EEPROM without corruption?
Edson,

I'm not using it since years. And I have an external brown-out
circuit taking care of the reset. All is working ok.

The problem is, when the AVR crashes, it can run any part of the code
and corrupt the EEPROM until the watchdog catches it.

I'm not allowed to change the hardware at this time, just software.

I would like to thank you all who responded to my question, it was
very helpful.

Thanks.
Mark Jordan ---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.767 / Virus Database: 514 - Release Date: 21/9/2004