avrdude-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avrdude-dev] chip_erase and cycle_count cleanup


From: Theodore A. Roth
Subject: Re: [avrdude-dev] chip_erase and cycle_count cleanup
Date: Mon, 1 Dec 2003 14:27:30 -0800 (PST)


On Mon, 1 Dec 2003, Jan-Hinnerk Reichert wrote:

> > > - Why is cycle count reset at 0xffff?
> >
> > Good question.  I think this is a bug.  I think it should be
> > compared against 0xffffffff.  A long time ago the cycle count was
> > 16 bits, but was later changed to 32 bits.  This code was progably
> > missed.
>
> There was another goodie in avr_get_cycle(). If the count was
> 0xffffffff it was set to 0xffff. So, every check against 0xffffffff
> was not doing anything.

Instead of checking against 0xffffffff, shouldn't it check against a
macro?

  #define CYCLES_ERASED ((uint32_t)-1)

Then the code becomes:

  if (!do_cycles && ((rc >= 0) && (cycles != CYCLES_ERASED))) {

This should guarantee that the number of ff's if correct for the size of
the storage used. Plus you eliminate a magic number, and the code
becomes a bit more readable.

Ted Roth




reply via email to

[Prev in Thread] Current Thread [Next in Thread]