EmbeddedRelated.com
Forums

AVR with Parallel Flash Memory

Started by NMMX May 26, 2010
Hi all,

I have a few questions on how to go about generate the correct waveforms
for reading/writing from/to an external flash memory using an AVR
microcontroller.

The AVR has enough I/O to allow direct connection between address, data and
control lines. I don't have to worry about counters/latches etc.

The AVR is using a 12MHz clock. How do you work out how long each cycle
will take?

Also with the AVR it seems there can be a delay when doing I/O operations,
there is a sync latch that is half a cycle, does anyone have any
information about this?

Currently I just insert random nops to delay cycles until it works as
expected. However, I would like to be able to work this out properly so can
write more efficient code.

Regards.

	   
					
---------------------------------------		
Posted through http://www.EmbeddedRelated.com
> > Currently I just insert random nops to delay cycles until it works as > expected. However, I would like to be able to work this out properly so > can > write more efficient code. > >
That's lucky...... all the info you need is in the Atmel data sheets, but I suspect you don't understand what is in front of you. Have you thouight about SPI flash ?
>> >> Currently I just insert random nops to delay cycles until it works as >> expected. However, I would like to be able to work this out properly so
>> can >> write more efficient code. >> >> >That's lucky...... all the info you need is in the Atmel data sheets, but
I
>suspect you don't understand what is in front of you. Have you thouight >about SPI flash ?
Parallel is used due to the requirements of the project. You're right, I don't fully understand everything within the datasheets hence why I am asking for a little bit of help to gain better understanding. I'm not in a electronics background for work/academic the only resource I have when I don't fully understand something is community forums and books. It is quite easy to insert enough no operation instructions so I can be sure that I am within the correct time frames, I simply want to be able to calculate it properly. I know a few issues that would effect this is things such as the sync latching. Regards. --------------------------------------- Posted through http://www.EmbeddedRelated.com
On May 26, 10:18=A0am, "NMMX" <alan.embedded@n_o_s_p_a_m.nmmx.net>
wrote:
> Hi all, > > I have a few questions on how to go about generate the correct waveforms > for reading/writing from/to an external flash memory using an AVR > microcontroller. > > The AVR has enough I/O to allow direct connection between address, data a=
nd
> control lines. I don't have to worry about counters/latches etc. > > The AVR is using a 12MHz clock. How do you work out how long each cycle > will take?
You mean other than 1/12000000 or 0.833333333333333333333333333333ns?
> > Also with the AVR it seems there can be a delay when doing I/O operations=
,
> there is a sync latch that is half a cycle, does anyone have any > information about this?
If the clock pulse is square and the latch is level activated, it will latch exactly half a cycle.
> > Currently I just insert random nops to delay cycles until it works as > expected. However, I would like to be able to work this out properly so c=
an
> write more efficient code.
Can't help you without knowing exactly what you are trying to do.
linnix schreef:
> On May 26, 10:18 am, "NMMX" <alan.embedded@n_o_s_p_a_m.nmmx.net> > wrote: >> Hi all, >> >> I have a few questions on how to go about generate the correct waveforms >> for reading/writing from/to an external flash memory using an AVR >> microcontroller. >> >> The AVR has enough I/O to allow direct connection between address, data and >> control lines. I don't have to worry about counters/latches etc. >> >> The AVR is using a 12MHz clock. How do you work out how long each cycle >> will take? > > You mean other than 1/12000000 or 0.833333333333333333333333333333ns?
I'm pretty sure he means something other than 0.833333333333333333333333333333ns, my guess is about two orders of magnitude more than that.
On May 26, 12:41=A0pm, Dombo <do...@disposable.invalid> wrote:
> linnix schreef: > > > On May 26, 10:18 am, "NMMX" <alan.embedded@n_o_s_p_a_m.nmmx.net> > > wrote: > >> Hi all, > > >> I have a few questions on how to go about generate the correct wavefor=
ms
> >> for reading/writing from/to an external flash memory using an AVR > >> microcontroller. > > >> The AVR has enough I/O to allow direct connection between address, dat=
a and
> >> control lines. I don't have to worry about counters/latches etc. > > >> The AVR is using a 12MHz clock. How do you work out how long each cycl=
e
> >> will take? > > > You mean other than 1/12000000 or 0.833333333333333333333333333333ns? > > I'm pretty sure he means something other than > 0.833333333333333333333333333333ns, my guess is about two orders of > magnitude more than that.
Yes, you are correct. 0.833333333333333333333333333333 microsec.
>On May 26, 10:18=A0am, "NMMX" <alan.embedded@n_o_s_p_a_m.nmmx.net> >wrote: >> Hi all, >> >> I have a few questions on how to go about generate the correct
waveforms
>> for reading/writing from/to an external flash memory using an AVR >> microcontroller. >> >> The AVR has enough I/O to allow direct connection between address, data
a=
>nd >> control lines. I don't have to worry about counters/latches etc. >> >> The AVR is using a 12MHz clock. How do you work out how long each cycle >> will take? > >You mean other than 1/12000000 or 0.833333333333333333333333333333ns? > >> >> Also with the AVR it seems there can be a delay when doing I/O
operations=
>, >> there is a sync latch that is half a cycle, does anyone have any >> information about this? > >If the clock pulse is square and the latch is level activated, it will >latch exactly half a cycle. > >> >> Currently I just insert random nops to delay cycles until it works as >> expected. However, I would like to be able to work this out properly so
c=
>an >> write more efficient code. > >Can't help you without knowing exactly what you are trying to do. > >
Thanks linnix, The half cycle is the minimum case, worst is one and half cycles. The datasheet also says that out instruction sets sync latch, however there are other ways of setting the port value such as sbi/cbi. I was hoping that someone could explain better how it effects the delay when setting a port value.
>Can't help you without knowing exactly what you are trying to do.
The AVR is directly connected to the flash. It sets the ports (address, data, control) in order to read or write from/to the flash memory. My current code works however I know its only because I have inserted extra nops to make sure I have the minimum hold/setup times for the waveform. With better understanding of how long each cycle is, this sync latch issue I would be able to modify my code to remove these redundant nops as I would be able to calculate the correct timing. Regards. --------------------------------------- Posted through http://www.EmbeddedRelated.com
linnix schreef:
> On May 26, 12:41 pm, Dombo <do...@disposable.invalid> wrote: >> linnix schreef: >> >>> On May 26, 10:18 am, "NMMX" <alan.embedded@n_o_s_p_a_m.nmmx.net> >>> wrote: >>>> Hi all, >>>> I have a few questions on how to go about generate the correct waveforms >>>> for reading/writing from/to an external flash memory using an AVR >>>> microcontroller. >>>> The AVR has enough I/O to allow direct connection between address, data and >>>> control lines. I don't have to worry about counters/latches etc. >>>> The AVR is using a 12MHz clock. How do you work out how long each cycle >>>> will take? >>> You mean other than 1/12000000 or 0.833333333333333333333333333333ns? >> I'm pretty sure he means something other than >> 0.833333333333333333333333333333ns, my guess is about two orders of >> magnitude more than that. > > Yes, you are correct. 0.833333333333333333333333333333 microsec.
And the correct answer is.... 83.3 ns!
On May 27, 8:01=A0am, "NMMX" <alan.embedded@n_o_s_p_a_m.nmmx.net> wrote:
> My > current code works however I know its only because I have inserted extra > nops to make sure I have the minimum hold/setup times for the waveform.
This is a little mangled. If you are talking to conventional parallel flash, that should need minimal timing patches on Read, but it will need care on Write. ie if you READ: Define all address values Float the IO port Pull OEN low [NOP insert point] Read BUS value Pull OEN Hi That will easily meet Address setup time, and leaves any pipeline effects for bus turnaround. It's easy to check if you know the expected read value. Write is going to need a scheme to load a page, or partial page, and then time, or poll, for the Write completion. Polling is probably the more revision-safe approach. -jg
"NMMX" <alan.embedded@n_o_s_p_a_m.nmmx.net> wrote in message
news:-IOdncrK-Z-b42DWnZ2dnUVZ_jWdnZ2d@giganews.com...
> > The AVR is directly connected to the flash. It sets the ports (address, > data, control) in order to read or write from/to the flash memory. My > current code works however I know its only because I have inserted extra > nops to make sure I have the minimum hold/setup times for the waveform.
If you create the bus cycles manually with a 12MHz AVR, you must have a very slow flash before you need to insert NOPs to get the timing right. What's the speed of the flash chip you're using? To give you an idea: I am currently working with a PIC18 running at 24MHz (at gun point, I must admit) and the flash has an access time of 100ns. No NOPs required and the total transfer speed is dead slow at 75kbyte/s.... Meindert