Yahoo Groups archive

AVR-Chat

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

Thread

Buffered interrupt driven EERPOM writes

Buffered interrupt driven EERPOM writes

2005-07-01 by arhodes19044

I want to do background writes of data to eeprom.

So, it needs to be interrupt driven.  Is it as simple as having a 
subroutine store the addresses of the source and destination in a 
global variable(s), then enable the eeprom interrupt, then do the 
first write  (&source[0] to &eeprom_dest[0])?

Then in the EEPROM ISR have it write sequentially from &source[1] to 
&eeprom_dest[1] for sizeof(source)-1 more bytes of data?  When the 
count of the bytes reaches zero, then the ISR would disable the EEPROM 
interrupt?

I guess there needs to be a eeprom_busy flag so nothing else tries to 
use the eeprom while the ISR is busy.

Any ideas or suggestions?

-Tony

Re: [AVR-Chat] Buffered interrupt driven EERPOM writes

2005-07-01 by Dave VanHorn

>
>I guess there needs to be a eeprom_busy flag so nothing else tries to
>use the eeprom while the ISR is busy.

There is an EEPROM ready ISR, so you could just do it from there.
If the EE is ready, then you can start another write.
You have to "kick start it" by doing the first write outside the int 
though, or you could do a dummy read.

Re: Buffered interrupt driven EERPOM writes

2005-07-01 by arhodes19044

I made this reply once, but it did not appear on the bulletinboard, so 
something must have screwed-up.


I figured I needed to kick-start the writes.  It woulf be elegant to 
have the ISR do thw WHOLE thing internally without the something 
external to the ISR making the first write.

I guess it is really not posible to call the ISR because it would 
become the foreground task, and I would end up not getting control 
back until the end of the writes. (not even considering rentrancy).

So, I think my strategy will be to create a buffer for the data in 
RAM, then call a subroutine with the address of the data and the 
sizeof the data.  Then have that subroutine determine the location of 
the EEPROM write, store those locations and length in a global 
variable,  then initiate the first write, and then return to the 
calling program.  The ISR will handle the rest of the transfer.

The first subroutine will set a flag/semaphore to indicate that the 
EEPROM is busy, and then the ISR will reset the flag/semaphore when 
done.

I will try it out.

-Tony
--- In AVR-Chat@yahoogroups.com, Dave VanHorn <dvanhorn@d...> wrote:
> 
> >
> >I guess there needs to be a eeprom_busy flag so nothing else tries 
to
Show quoted textHide quoted text
> >use the eeprom while the ISR is busy.
> 
> There is an EEPROM ready ISR, so you could just do it from there.
> If the EE is ready, then you can start another write.
> You have to "kick start it" by doing the first write outside the int 
> though, or you could do a dummy read.

Re: [AVR-Chat] Re: Buffered interrupt driven EERPOM writes

2005-07-01 by Johnathan Corgan

arhodes19044 wrote:

> So, I think my strategy will be to create a buffer for the data in 
> RAM, then call a subroutine with the address of the data and the 
> sizeof the data.  Then have that subroutine determine the location of 
> the EEPROM write, store those locations and length in a global 
> variable,  then initiate the first write, and then return to the 
> calling program.  The ISR will handle the rest of the transfer.

This is a pretty tried and true algorithm for sending a block of data 
out a peripheral that interrupts when it is ready for the next bit of 
data, regardless of microprocessor and microcontroller architecture. 
Kick start the first byte and let the ISR go from there.  I have old 
8250 serial port code I wrote in 1989 for an 80286 that works the same way!

-Johnathan

Re: Buffered interrupt driven EERPOM writes

2005-07-02 by arhodes19044

Thanks for confirming my general approach.  The devil is in the 
details, of course.  I am surprised that there is no generic 
interrupt driven subroutinr and matching ISR.  In its most generic 
form it would be quite functional and useful.  So.... I will write 
it and post it!

-Tony


--- In AVR-Chat@yahoogroups.com, Johnathan Corgan <jcorgan@a...> 
wrote:
> arhodes19044 wrote:
> 
> > So, I think my strategy will be to create a buffer for the data 
in 
> > RAM, then call a subroutine with the address of the data and the 
> > sizeof the data.  Then have that subroutine determine the 
location of 
> > the EEPROM write, store those locations and length in a global 
> > variable,  then initiate the first write, and then return to the 
> > calling program.  The ISR will handle the rest of the transfer.
> 
> This is a pretty tried and true algorithm for sending a block of 
data 
> out a peripheral that interrupts when it is ready for the next bit 
of 
> data, regardless of microprocessor and microcontroller 
architecture. 
> Kick start the first byte and let the ISR go from there.  I have 
old 
> 8250 serial port code I wrote in 1989 for an 80286 that works the 
same way!
> 
> -Johnathan

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.