I have two 24LC512 chips used in a memory array controlled by an 18F2525. I am trying to compute the %age 'full' the memory chips are together. I can do it in MS Excel, but not in PBP...
Here is what I am trying to do.
Chipselect = the chips - can be a '1' or a '2'. (Byte)
Memperc = %age of memory used (byte)
Address = current memory pointer (on either chip). Increments in 128 (Word)
Addrsm = address/1000 (byte)
When I want to compute memory %age, I use this:
if chipselect = 1 then
addrsm = address/1000
memperc = (addrsm/2)/64 ' 0-50%
else
addrsm = address/1000
memperc = (addrsm+64)/128 '50-100%
endif
IN EXCEL, this works fine - for example: lets say Address = 40832 and Chipselect = 2
Addrsm = 40832/1000 - > gives 40.832
Chipselect is = '2' so,
memperc = 40.832+64 = 104.832, /128 = .819
What I get is '0'.... I want 81.9% so I can display the memory.. REALLY I want to get a number like '819' so I can display using:
LCDout $fe, L4, "Memory%",#memperc dig 2, #memperc dig 1, ".", dec1 memperc,
Any PBP Math gurus out there?
Excel file with how I want it to work is attached.
Bookmarks