EEPROM problem

LPG

New Member
I have made up a circuit with a picaxe 08. It has pins 0,1,2 and 4 as outputs to LEDs. It has pin 3 as a serial and trigger input. It is loaded with the following program:
Code:
symbol unitid = 1
let dirs = %00010111
if pin3 = 1 then
	serin 3,N2400,(24,"p",unitid)	
	pins = %00010111	
	serin 3,N2400,(60,"v"),b0
	write 1,b0
end if
read 1,b0
let pins = b0
I have a switch between + and pin3, as well as a serial input cable. the idea is to have several of these. when turned on, depending on the status of pin3, they enter program mode or display mode.
Program: The units wait for their id to be called out. they then set all pins high. It waits for input of a pins value, and writes it to EEPROM 1.
Display: The units read EEPROM 1 and sets it to pins.
I believe the error is in the write command, as when I set it with preloaded messages it can read them. also if i change it so the serin goes
Code:
serin 3,N2400m(60,"v"),pins
it sets the pins to the right value.

I am confused by this problem and would appreciate any help people can give me.
 

Andrew Cowan

Senior Member
What does the following code produce? (Press F8 after the download has completed).

Code:
Main:
For b1=0 to 10
write 1,b1
pause 1000
read 1,b2
sertxd (#b2,13,10)
next b1
goto main
Do you have the 1N4148 diode on pin3 to let it do serial comms? I can't see any problem with your code.
 

Andrew Cowan

Senior Member
I'd be interested to see what is being written to the EEPROM. What does this give?

Code:
symbol unitid = 1
let dirs = %00010111
if pin3 = 1 then
	serin 3,N2400,(24,"p",unitid)	
	pins = %00010111	
	serin 3,N2400,(60,"v"),b0
	sertxd (#b0,13,10)
end if
The # displays the ASCII value.

A
 

hippy

Ex-Staff (retired)
I cannot see any reason the code in the first post would not work. Internal data Eeprom does not require a PAUSE after it when writing. If the program is reading the correct value directly into "pins" it should also have the same value in "b0" and a WRITE then READ should work; Andrew's test program shows WRITE and READ are working as expected.

You can use SERTXD or DEBUG to report what is going on as the program progresses a simple test is to verify that what is written by WRITE can be READ ...

Code:
symbol unitid = 1
let dirs = %00010111
if pin3 = 1 then
        serin 3,N2400,(24,"p",unitid)	
        pins = %00010111	
        serin 3,N2400,(60,"v"),b0
        write 1,b0
        [b]read 1,b1
        if b1 <> b0 then
          do
             pins = %00010111
             pause 250
             pins = %00000000
             pause 250
           loop
        end if[/b]
end if
read 1,b0
let pins = b0
If the LED's flash quickly it means that what was stored is not as was received, if there's no flashing the problem is with the data received.
 

LPG

New Member
The lights flash...
After adding a serout i found that the read statement is recieving 0, even though the variable passed to the write statement contained 17.
You can use EEPROM on 08 the same as on other chips?
 

hippy

Ex-Staff (retired)
Very odd. Yes, Eeprom on the 08 is the same as on any other PICAXE ( except there's only 128 bytes of it ).

It sounds like the Eeprom has worn itself out or the PICAXE has been damaged. You could try using a different Eeprom address ( WRITE 0,b0 / READ 0,b0 ) and see if that suffers the same problem.

Do you have the diode from pin 3 to +V as mentioned in post #2 ?

What are you using to power the 08 and what voltage is it currently running at ?

Also, run the code in post #2 again and see if it behaves differently to how it did before. You should see numbers 0 to 10 repeating if the Eeprom is working as expected.
 

LPG

New Member
Thanks a bunch!
I was ignorant and didn't read the stuff about a diode.
It works now!
Thank you again.
 

hippy

Ex-Staff (retired)
If nothing else you've proved the necessity of the diode and the weird behaviour which can happen without it ! Glad to hear it's working.
 

boriz

Senior Member
“I was ignorant”

Nope.

Ignorant is ... “If <magic supernatural deity> had meant us to <whatever>, he would have given us <whatever>”. Or ... “It’s a miracle.” Etc.

What you did was the opposite. You studied, tried, failed, learned, tried again, succeeded. Same thing that gave us Fire, Wheels, Electricity, Flight etc.

So pat yourself on the back and carry on ‘creating’ :)
 
Top