Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

EEPROM writing with elec. noise

EEPROM writing with elec. noise

2006-04-06 by Gary J. Melvin

Hello,

"Long time listener, first time caller."

I've taken on an ATmega16-based project.  One of the requirements is
that I need to write up to 3 bytes of data to EEPROM in a potentially
electrically noisy environment.  I've never used its EEPROM before, but
it looks relatively uncomplicated.

My client has another product in a similar application which has been
causing them a lot of grief with random EEPROM write errors, presumably
due to noise glitches.  (They use the built-in Brown Out feature  -
both trigger settings produced the same results.)  Obviously, this needs
to be solved with this new product.

Here's the approach I suggested to them - feel free to shoot it down.
I've asked them to add a voltage divider before the regulator.  Run it
through a Schmitt Trigger to an input pin on the '16.  I've also asked
that they beef up the regulated voltage filtering to ensure at least 50
mSec of adequate power to carry it through a total drop out of the
supply.  (8.3 mSec, minimum, per EEPROM erase/write cycle times 3 bytes
of data = 25 mSec ... then double it for peace of mind.)  Before writing
the 1, 2, or 3 bytes of data, I'll check the status of the pin - if low,
I won't do the write(s).

I'm open to suggestions.  If you have a better approach or a
bullet-proof algorithm, please enlighten me.

Thanks!

Gary.

Re: [AVR-Chat] EEPROM writing with elec. noise

2006-04-06 by James Hatley

Hello Gary,

Well ... an interesting problem ... my opinions follow ...

If it was me the first thing would be to find the source of the EEPROM write
errors in the similar application.

Check the read/write code ... check the grounds ... the bypassing ... the
filtering ... etc. Find the problem.

Leave no stone unturned so to speak.

All else before finding the problem is by your own words presumption.

Find the problem first then evaluation fixes if necessary.

Jim



----- Original Message ----- 
Show quoted textHide quoted text
From: "Gary J. Melvin" <n9auw@garmeltech.com>
To: <AVR-Chat@yahoogroups.com>
Sent: Thursday, April 06, 2006 8:39 AM
Subject: [AVR-Chat] EEPROM writing with elec. noise


> Hello,
>
> "Long time listener, first time caller."
>
> I've taken on an ATmega16-based project.  One of the requirements is
> that I need to write up to 3 bytes of data to EEPROM in a potentially
> electrically noisy environment.  I've never used its EEPROM before, but
> it looks relatively uncomplicated.
>
> My client has another product in a similar application which has been
> causing them a lot of grief with random EEPROM write errors, presumably
> due to noise glitches.  (They use the built-in Brown Out feature  -
> both trigger settings produced the same results.)  Obviously, this needs
> to be solved with this new product.
>
> Here's the approach I suggested to them - feel free to shoot it down.
> I've asked them to add a voltage divider before the regulator.  Run it
> through a Schmitt Trigger to an input pin on the '16.  I've also asked
> that they beef up the regulated voltage filtering to ensure at least 50
> mSec of adequate power to carry it through a total drop out of the
> supply.  (8.3 mSec, minimum, per EEPROM erase/write cycle times 3 bytes
> of data = 25 mSec ... then double it for peace of mind.)  Before writing
> the 1, 2, or 3 bytes of data, I'll check the status of the pin - if low,
> I won't do the write(s).
>
> I'm open to suggestions.  If you have a better approach or a
> bullet-proof algorithm, please enlighten me.
>
> Thanks!
>
> Gary.
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>

Re: [AVR-Chat] EEPROM writing with elec. noise

2006-04-07 by Mark Jordan

On 6 Apr 2006 at 10:39, Gary J. Melvin wrote:

> 
> I'm open to suggestions.  If you have a better approach or a
> bullet-proof algorithm, please enlighten me.
> 

	Would you please post the routine you used to write to the EEPROM?

	Thanks.

Re: [AVR-Chat] EEPROM writing with elec. noise

2006-04-07 by Robert Adsett

At 10:39 AM 4/6/2006 -0500, Gary J. Melvin wrote:
>My client has another product in a similar application which has been
>causing them a lot of grief with random EEPROM write errors, presumably
>due to noise glitches.  (They use the built-in Brown Out feature  -
>both trigger settings produced the same results.)  Obviously, this needs
>to be solved with this new product.

<snip>

>I'm open to suggestions.  If you have a better approach or a
>bullet-proof algorithm, please enlighten me.

Add several copies of the data with some sort of check sum or guard.  That 
gives you the chance of recovering from an error or at least (and more 
importantly) noticing it.  With only three bytes a simple mirrored copy 
might be the simplest effective method.  An xor of the data with its mirror 
will be zero if they are valid.

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,   be 
they legal, genetic, or physical.  If you don't believe me, try to chew a 
radio signal. "  -- Kelvin Throop, III
http://www.aeolusdevelopment.com/

Re: [AVR-Chat] EEPROM writing with elec. noise

2006-04-07 by John Samperi

At 12:10 PM 7/04/2006, you wrote:
>         Would you please post the routine you used to write to the EEPROM?

All your precautions will come to nothing unless you
remember to turn off interrupts whilst writing to the
EEPROM. It will work most of the time / sometimes but
you are likely to get write errors if an interrupt happens
during the write cycle.
Here is my EEPROM write routine in assembler (sorry don't do C :-) )

;Put 1 byte in temp to address pointed by Z.
put_ieep_byte:
         sbic    EECR,EEWE               ;Wait for completion of previous write
         rjmp    put_ieep_byte
         cli
         out     EEARH,zh                ;Set up address (in Z ) in 
address register
         out     EEARL,zl
         out     EEDR,temp               ;Write data (temp) to data register
         sbi     EECR,EEMWE              ;Write logical one to EEMWE
         sbi     EECR,EEWE               ;Start eeprom write by setting EEWE
         sei
         ret

Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495       Fax (02) 9674-8745
Email: john@ampertronics.com.au
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************

RE: [AVR-Chat] EEPROM writing with elec. noise

2006-04-07 by Larry Barello

I recently experienced severe eeprom problems when switching from a mega32
to a mega128.  The solution, it turned out, was to lengthen the start up
time for the external resonator.

This was surprising, to me;  Ever since the BOD has been available I have
had zero eeprom problems (I even have lost the habit of setting the EEPROM
pointer to zero after use and not using the first slot...).

Although I know it is proper defensive programming to do things like
multiple copies, checksums, etc.  I find it is best to figure out what the
problem is and let the hardware do its thing, which is extremely reliable
operation.

I do use checksums (or CRC8 or 16) to flag "empty" memory (or memory layout
that has changed) so the code can initialize it but I can't recall ever
taking a memory hit that wasn't code or hardware setup related (i.e. my
fault).  After figuring out the error the faults always go away.  Sometimes
the fault is obscure (ref, the reminder to disable interrupts while
writing).  But is always turns out to be a code fault.

Take my experiences with a grain-o-salt, your mileage may vary.


-----------
Larry Barello
www.barello.net


| -----Original Message-----
| From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
| Of Gary J. Melvin
| Sent: Thursday, April 06, 2006 8:40 AM
| To: AVR-Chat@yahoogroups.com
| Subject: [AVR-Chat] EEPROM writing with elec. noise
| 
| Hello,
| 
| "Long time listener, first time caller."
| 
| I've taken on an ATmega16-based project.  One of the requirements is
| that I need to write up to 3 bytes of data to EEPROM in a potentially
| electrically noisy environment.  I've never used its EEPROM before, but
| it looks relatively uncomplicated.
| 
| My client has another product in a similar application which has been
| causing them a lot of grief with random EEPROM write errors, presumably
| due to noise glitches.  (They use the built-in Brown Out feature  -
| both trigger settings produced the same results.)  Obviously, this needs
| to be solved with this new product.
| 
| Here's the approach I suggested to them - feel free to shoot it down.
| I've asked them to add a voltage divider before the regulator.  Run it
| through a Schmitt Trigger to an input pin on the '16.  I've also asked
| that they beef up the regulated voltage filtering to ensure at least 50
| mSec of adequate power to carry it through a total drop out of the
| supply.  (8.3 mSec, minimum, per EEPROM erase/write cycle times 3 bytes
| of data = 25 mSec ... then double it for peace of mind.)  Before writing
| the 1, 2, or 3 bytes of data, I'll check the status of the pin - if low,
| I won't do the write(s).
| 
| I'm open to suggestions.  If you have a better approach or a
| bullet-proof algorithm, please enlighten me.
| 
| Thanks!
| 
| Gary.
| 
| 
| 
| 
| Yahoo! Groups Links
| 
| 
| 
| 
|

Re: [AVR-Chat] EEPROM writing with elec. noise

2006-04-07 by David VanHorn


;Put 1 byte in temp to address pointed by Z.
put_ieep_byte:
sbic EECR,EEWE ;Wait for completion of previous write
rjmp put_ieep_byte
cli
out EEARH,zh ;Set up address (in Z ) in
address register
out EEARL,zl
out EEDR,temp ;Write data (temp) to data register
sbi EECR,EEMWE ;Write logical one to EEMWE
sbi EECR,EEWE ;Start eeprom write by setting EEWE
sei
ret
But you don't really need to CLI till just before the SBI EECR.
That's the only part that has to be atomic.
This does assume that your ISR preserves Z

--
Feel the power of the dark side! Atmel AVR

Re: [AVR-Chat] EEPROM writing with elec. noise

2006-04-08 by Gary J. Melvin

Thanks to all that have responded.

Shortly after I sent the email I thought about the possibility of a pin
seeing a negative voltage.  Anybody know what the effect, if any, would
be on the processor?  How tolerant is the ATmega16 of this condition?

I'd gladly submit the code to the group, but it's not available.  My
client wanted me to debug the existing product (with the EEPROM write
problems), but the original author has a contractual noose around the
code and won't/can't let loose of it.  I told my client I'd be wasting
his money trying to debug something without being able to review the
code and insert debug statements.  They've decrease the erroneous EEPROM
writes by making some code changes, but I've not been involved in that.
 The weird part about this problem is that it affects EEPROM locations
that are never written to after the initial set up.  They're suspicious
that somehow the address lines are getting modified (see previous
paragraph).

With this new product, my client will own the code.  It's in the early
stages - hardware has been designed (not by me) but I haven't written
any code yet.  Officially the project hasn't gotten the green light.
I've requested some minor hardware changes which will allow very early
brownout detection (independent of the internal BOD) ... details in
original message.

Thanks again for everyone's ideas.

James Hatley wrote:
Show quoted textHide quoted text
> Hello Gary,
> 
> Well ... an interesting problem ... my opinions follow ...
> 
> If it was me the first thing would be to find the source of the EEPROM write
> errors in the similar application.
> 
> Check the read/write code ... check the grounds ... the bypassing ... the
> filtering ... etc. Find the problem.
> 
> Leave no stone unturned so to speak.
> 
> All else before finding the problem is by your own words presumption.
> 
> Find the problem first then evaluation fixes if necessary.
> 
> Jim
> 
> 
> 
> ----- Original Message -----
> From: "Gary J. Melvin" <n9auw@garmeltech.com>
> To: <AVR-Chat@yahoogroups.com>
> Sent: Thursday, April 06, 2006 8:39 AM
> Subject: [AVR-Chat] EEPROM writing with elec. noise
> 
> 
>> Hello,
>>
>> "Long time listener, first time caller."
>>
>> I've taken on an ATmega16-based project.  One of the requirements is
>> that I need to write up to 3 bytes of data to EEPROM in a potentially
>> electrically noisy environment.  I've never used its EEPROM before, but
>> it looks relatively uncomplicated.
>>
>> My client has another product in a similar application which has been
>> causing them a lot of grief with random EEPROM write errors, presumably
>> due to noise glitches.  (They use the built-in Brown Out feature  -
>> both trigger settings produced the same results.)  Obviously, this needs
>> to be solved with this new product.
>>
>> Here's the approach I suggested to them - feel free to shoot it down.
>> I've asked them to add a voltage divider before the regulator.  Run it
>> through a Schmitt Trigger to an input pin on the '16.  I've also asked
>> that they beef up the regulated voltage filtering to ensure at least 50
>> mSec of adequate power to carry it through a total drop out of the
>> supply.  (8.3 mSec, minimum, per EEPROM erase/write cycle times 3 bytes
>> of data = 25 mSec ... then double it for peace of mind.)  Before writing
>> the 1, 2, or 3 bytes of data, I'll check the status of the pin - if low,
>> I won't do the write(s).
>>
>> I'm open to suggestions.  If you have a better approach or a
>> bullet-proof algorithm, please enlighten me.
>>
>> Thanks!
>>
>> Gary.
>>
>>
>>
>>
>> Yahoo! Groups Links
>>
>>
>>
>>
>>
>>
>>
> 
> 
> 
> ------------------------------------------------------------------------
> YAHOO! GROUPS LINKS
> 
>     *  Visit your group "AVR-Chat
>       <http://groups.yahoo.com/group/AVR-Chat>" on the web.
>        
>     *  To unsubscribe from this group, send an email to:
>        AVR-Chat-unsubscribe@yahoogroups.com
>       <mailto:AVR-Chat-unsubscribe@yahoogroups.com?subject=Unsubscribe>
>        
>     *  Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>       Service <http://docs.yahoo.com/info/terms/>. 
> 
> 
> ------------------------------------------------------------------------
>

Re: [AVR-Chat] EEPROM writing with elec. noise

2006-04-09 by David VanHorn



Shortly after I sent the email I thought about the possibility of a pin
seeing a negative voltage. Anybody know what the effect, if any, would
be on the processor? How tolerant is the ATmega16 of this condition?
That IS one of those "don't go there" conditions with any part.
EE on all processors is dependent on some conditions.
Loosing power in mid-write is a bad thing. /Reset asserted, bugs in code that modify the EE registers, bugs that call the EE routines with junk data, similar problems during the read cycles..

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.