From: "varsha" <[EMAIL PROTECTED]>

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)
  {
     process_16_sdram_bytes(sdram_adr);
     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,
  -=Dave




_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to