PDA

View Full Version : dWord variables



xnihilo
- 17th September 2008, 21:26
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?

mackrackit
- 17th September 2008, 23:16
PBP 2.50 has long variables.

http://www.melabs.com/resources/articles/longs.pdf

skimask
- 17th September 2008, 23:32
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)

[quote]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...

BrianT
- 17th September 2008, 23:41
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

xnihilo
- 17th September 2008, 23:55
[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)


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.

xnihilo
- 17th September 2008, 23:57
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.

xnihilo
- 17th September 2008, 23:59
PBP 2.50 has long variables.

http://www.melabs.com/resources/articles/longs.pdf

Really? Nice.

rmteo
- 18th September 2008, 00:45
What are you dealing with exactly? Seems like there is some disconnect between point A and point B here...
PM's sent.