EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Saving in EEPROM without corruption?

Started by Mark Jordan September 19, 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


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




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

_______________________________




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
---------------------------------


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 >
> --------------------------------- >
>
> click here > ______________________________________________________________________
> Yahoo! Groups Links
> * To
>




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.


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




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


--- 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




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



The 2024 Embedded Online Conference