eeprom readnot reliable with binary values?

moorea21

Senior Member
Running this as a simulation, not tried on the picaxe itself yet (lcd no longer working; apparently hooking it up to 12V supply kills the right hand side of the screen, so I can only see 8 digit numbers on each line now...)
The code below should read 2 consecutive eeprom addresses into a word variable. Sometimes it does this correctly, sometimes it appears to make up a value that isn't like anything in any eeprom address.
For instance, when b0 = 5, b2,b3 should be 00000001,00010000.
And indeed that is what is returned to these variables.

On the other hand, when b0 = 10, b2, b3 should be 00000010,00000010,
but is apparently 00001010,00001010 instead; these are not even values stored somewhere else in eeprom.

Surely either this code should work, or not work? Why the extra phantom '1's??

Code:
#picaxe 08m2

EEPROM  2, (00000001,00000001,   00000001,00000010,   00000001,00000100,   00000001,00001000)
EEPROM  10,(00000001,00010000,   00000001,00100000,   00000001,01000000,   00000001,10000000)
EEPROM  18,(00000010,00000001,   00000010,00000010,   00000010,00000100,   00000010,00001000) 
EEPROM  26,(00000010,00010000,   00000010,00100000,   00000010,01000000,   00000010,10000000)
EEPROM  34,(00000011,00000001,   00000011,00000010,   00000011,00000100,   00000011,00001000)
EEPROM  42,(00000011,00010000,   00000011,00100000,   00000011,01000000,   00000011,10000000)
EEPROM  50,(00000100,00000001,   00000100,00000010,   00000100,00000100,   00000100,00001000)
EEPROM  58,(00000100,00010000,   00000100,00100000,   00000100,01000000,   00000100,10000000)
EEPROM  66,(00000101,00000001,   00000101,00000010,   00000101,00000100,   00000101,00001000)
EEPROM  74,(00000101,00010000,   00000101,00100000,   00000101,01000000,   00000101,10000000)
EEPROM  82,(00000110,00000001,   00000110,00000010,   00000110,00000100,   00000110,00001000)
EEPROM  90,(00000110,00010000,   00000110,00100000,   00000110,01000000,   00000110,10000000)
EEPROM  98,(00000111,00000001,   00000111,00000010,   00000111,00000100,   00000111,00001000,   00000111,00010000)

init:-	
	pause 50
	serout C.2,N2400,(254,1)
	pause 500

	
main:

	serout C.2,N2400, (254,128)
	serout C.2,N2400, (#b0)		'puts N on lcd
	b0 = 9				'SHOULD BE:-	b0 = 10: 00000010,00000010; b0 = 5: 00000001,00010000
	b1 = 2 * b0				'IS			b0 = 10: 00001010,00001010; b0 = 5: 00000001,00010000
	read b1, WORD w1			
	serout C.2,N2400, (254,192)
	serout C.2,N2400, (#b2, #b3)
	goto main
 

hippy

Technical Support
Staff member
SEROUT doesn't issue leading zeroes for variable values so it's not clear what you are actually describing.

Rather than output to an LCD where there can be all sorts of problems with trailing numbers being left over from previous output it is better to use SERTXD ...

Code:
main:
  b0 = 9
  b1 = 2 * b0
  read b1, WORD w1
  SerTxd( "w1=", #w1, CR, LF )
  Goto main
 
Last edited:

hippy

Technical Support
Staff member
Solved -

EEPROM 2, (00000001,00000001,

Those aren't binary numbers. You need a % in front of a binary number.
 
Top