dWord variables


Closed Thread
Results 1 to 8 of 8

Thread: dWord variables

  1. #1
    xnihilo's Avatar
    xnihilo Guest

    Smile dWord variables

    Hello,

    I need to work with 24 bits addresses for a 1024 bits memory, last byte of the memory will be at $01FFFF. 256 bytes make a PAGE and 256 PAGES make a SECTOR and there are 2 SECTORS.
    I was wondering how I could increment such address.

    There are no Doubleword in PBP, right?

    Then I should use for example:

    address_low VAR WORD
    address_high VAR WORD

    I will fill the memory with words of data si I will have to increment the memory by increments of 2 bytes.

    If I increment the address of 2 bytes at every iteration in a loop, I will use:

    address_low == address_low + 2
    If (address_low > $ffff) then 'if I was at address_low = $ffff
    address_low = $02 '---> do I have to set the value myself or will there be a rollover ???
    address_high = (address_high + 1) 'start in second block
    endif

    Isn't there an easier way to increment a double word variable?

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Dave
    Always wear safety glasses while programming.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    [QUOTE=xnihilo;62476]I need to work with 24 bits addresses for a 1024 bits memory[quote]
    24 address bits get you 16,777,216 bytes of memory ( 2 ^ 24)

    of address, last byte of the memory will be at $01FFFF.
    Last byte with 24 bits should be $FFFFFF

    256 bytes make a PAGE and 256 PAGES make a SECTOR and there are 2 SECTORS.
    If we're still talking about the same thing, you should have 256 'SECTOR's

    What are you dealing with exactly? Seems like there is some disconnect between point A and point B here...

  4. #4


    Did you find this post helpful? Yes | No

    Default 24 bit memory addressing

    I am using the M25P128 memory chip which needs a 24 bit address. I use

    Addr0 var byte ' LSB of 24 bit address
    Addr1 var byte
    Addr2 var byte ' MSB of 24 bit address

    Every time Addr0 overflows I increment Addr1.
    Every time Addr1 overflows I increment Addr2.

    In my case I run Addr2 all the way up to FF. In your case Addr2 will only be 0 or 1.

    HTH
    BrianT

  5. #5
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default

    [QUOTE=skimask;62484][QUOTE=xnihilo;62476]I need to work with 24 bits addresses for a 1024 bits memory
    24 address bits get you 16,777,216 bytes of memory ( 2 ^ 24)


    Last byte with 24 bits should be $FFFFFF


    If we're still talking about the same thing, you should have 256 'SECTOR's

    What are you dealing with exactly? Seems like there is some disconnect between point A and point B here...
    I wrote 1024 bits but I meant 1024 Kilobits memory (1Mega) ... Sorry... It's late...
    I have to access up to byte $01ffff.
    So yes, I have only 2 sectors: 256bytes * 256 pages * 2 = 128Kbytes = 1024 Kbits

    I'm dealing with SPI serial eeprom 25AA1024 from Microchip.

  6. #6
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BrianT View Post
    I am using the M25P128 memory chip which needs a 24 bit address. I use

    Addr0 var byte ' LSB of 24 bit address
    Addr1 var byte
    Addr2 var byte ' MSB of 24 bit address

    Every time Addr0 overflows I increment Addr1.
    Every time Addr1 overflows I increment Addr2.

    In my case I run Addr2 all the way up to FF. In your case Addr2 will only be 0 or 1.

    HTH
    BrianT
    Right. Thanks.
    I use address_low as a word var and address_high as a word var.
    When address_low overflows, it increments address_high by 1.

    I use a word var because with that I can increment this variable up to $FF.

    I think it should do the trick.

  7. #7
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Really? Nice.

  8. #8
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    What are you dealing with exactly? Seems like there is some disconnect between point A and point B here...
    PM's sent.

Similar Threads

  1. Max Variables
    By shawn in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 19th January 2008, 04:05
  2. Changing declared variables names on the fly
    By jessey in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th December 2006, 06:34
  3. 32-bit Variables and DIV32, Hourmeter 99999.9
    By Darrel Taylor in forum Code Examples
    Replies: 9
    Last Post: - 23rd November 2006, 07:23
  4. Variables not appearing in Watch Window MPLabv7.3
    By jd76duke in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th June 2006, 14:36
  5. Problems with variables
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th December 2004, 18:37

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts