Atmel AVR Microcontroller discussion group.
Saving in EEPROM without corruption? - Mark Jordan - Sep 19 21:25:00 2004
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

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
Re: Saving in EEPROM without corruption? - Michael Monteith - Sep 22 9:31:00 2004
Mark,
You might could employ some CRC checking or do like in the disk
world have redundant copies of code.
But I think the biggest issue is doing the best not to have
crashes. It's good you have recovery but in some proccesses you
can't afford it to go down.
Basically what I'm saying is that you can take a two-prong
approach. Have a good recovery but also take care of the noise
issue. I had to design circuits that worked around TIG welders and
huge cables all around carrying large amounts of current. You could
hang a O-scope probe in mid air and get signals you wouldn't
believe. But good shielding around your project, good grounding
techniques, and good filtering on leads in and out of the project
will do wonders.
Michael
--- In avrclub@avrc..., "Mark Jordan" <mark@c...> wrote:
>
> 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

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
Re: [AVR club] Re: Saving in EEPROM without corruption? - SFDFD DFDS - Sep 22 10:47:00 2004
how do you deal with exceptions for atmel applications
--- Michael Monteith <michael_r_monteith@mich...>
wrote:
> Mark,
> You might could employ some CRC checking or do
> like in the disk
> world have redundant copies of code.
>
> But I think the biggest issue is doing the best not
> to have
> crashes. It's good you have recovery but in some
> proccesses you
> can't afford it to go down.
>
> Basically what I'm saying is that you can take a
> two-prong
> approach. Have a good recovery but also take care
> of the noise
> issue. I had to design circuits that worked around
> TIG welders and
> huge cables all around carrying large amounts of
> current. You could
> hang a O-scope probe in mid air and get signals you
> wouldn't
> believe. But good shielding around your project,
> good grounding
> techniques, and good filtering on leads in and out
> of the project
> will do wonders.
>
> Michael
>
> --- In avrclub@avrc..., "Mark Jordan"
> <mark@c...> wrote:
> >
> > 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
_______________________________

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
[AVR club] Converting current to PWM - Andrew Lim - Sep 22 22:07:00 2004
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
---------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
Re: [AVR club] Converting current to PWM - mbd - Sep 22 22:21:00 2004
A resistor?
On Wed, 2004-09-22 at 21:07, Andrew Lim wrote:
> 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 Sponsor
> ADVERTISEMENT
> click here
> ______________________________________________________________________
> Yahoo! Groups Links
> * To

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
Re: [AVR club] Converting current to PWM - Dave VanHorn - Sep 22 22:27:00 2004
At 09:21 PM 9/22/2004, mbd wrote:
>A resistor?
>
>On Wed, 2004-09-22 at 21:07, Andrew Lim wrote:
>> 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?
Think of an oscillator, like a 555 circuit.
The capacitor discharge time can be made constant, and the cap charge time variable,
according to the input current. There you have it, PWM directly from current.
Look at the 555 data sheets and application notes.
Of course you could use a resistor to convert the current to a voltage, and read that with
an A/D, and output that as PWM.

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
RE: [AVR club] Converting current to PWM - joseph torelli - Sep 23 1:37:00 2004
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

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
Re: [AVR club] Re: Saving in EEPROM without corruption? - Mark Jordan - Sep 23 7:31:00 2004
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
On 23 Sep 2004 at 12:06, Edson L. Bestvina 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
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
Re: Saving in EEPROM without corruption? - Edson L. Bestvina - Sep 23 8:06:00 2004
--- 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

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
RES: [AVR club] Re: Saving in EEPROM without corruption? - Edson L. Bestvina - Sep 23 10:07:00 2004
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
[Non-text portions of this message have been removed]

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
Re: [AVR club] Re: Saving in EEPROM without corruption? - ary ardianto - Sep 23 10:31:00 2004
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 SponsorADVERTISEMENT
---------------------------------
Yahoo! Groups Links
To
---------------------------------

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
RES: [AVR club] Re: Saving in EEPROM without corruption? - Edson L. Bestvina - Sep 23 12:51:00 2004
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! Groups SponsorADVERTISEMENT
---------------------------------
"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
[Non-text portions of this message have been removed]

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
Re: RES: [AVR club] Re: Saving in EEPROM without corruption? - Dave VanHorn - Sep 23 12:58:00 2004
>
>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.

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
RES: RES: [AVR club] Re: Saving in EEPROM without corruption? - Edson L. Bestvina - Sep 23 13:32:00 2004
Dave
Why? I don´t 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
[Non-text portions of this message have been removed]

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
RE: [AVR club] Converting current to PWM - Andrew Lim - Sep 26 6:28:00 2004
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 SponsorADVERTISEMENT
---------------------------------
Yahoo! Groups Links
To
---------------------------------

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )