[Top][All Lists]

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

RE: [avr-gcc-list] sdram adress/length

From: Dave Hansen
Subject: RE: [avr-gcc-list] sdram adress/length
Date: Thu, 10 Nov 2005 09:15:59 -0500

From: "varsha" <address@hidden>

hello all,
i am using avr-gcc (GCC) 3.4.3, and using ATmega16 ,
and writng the code for copying sdram data int flash, in c language.
There are three address bytes and three length bytes for sdram.
At a time i can read 16 bytes from sdram, then i want to decerment the length and incerement the address value bye 16. how to increment address value(or decrement the length), by using a single variable. i dont want use three different bytes, because then propogating carry becomes a problem.. is there any way , by which we can define a data type which takes three bytes of memory...?

Obviously, you could use unsigned long, which solves all your problems at the cost of one unused byte. Each.

  unsigned long sdram_adr = 0;
  unsigned long sdram_len = 0x1000000;

  while (sdram_len >0)
     sdram_len -= 16;
     sdram_adr += 16;

However, access to unsigned long is not atomic. If you are going to be accessing these values in interrupt service routines, you'll have to protect access in mainline code so they aren't interrupted.

Hope this helps,

reply via email to

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