How to save a variable (by Rafael Benetti)
Hi!
I'm using PIC 16F628A. Almost everything is working, but there's a problem happen when i try to save a variable in EPROM. This value isn't recoverd when PIC is powered up.
I'm sending a part of the program when i save and recoverd value.
Thanks your attention.
Rafael Benetti
(no subject) (by Jonathan Westhues)
There's no need to put the PERSIST op with stuff before it in the rung. That instruction will automatically save the variable only when it changes, so it's okay if its rung-in condition is just always true.
See the attached example. The inputs Xon and Xoff turn the output Yout on and off respectively, and that state is persistent across resets.
Though it's possible that persistent variables are broken for the '628A. I think the PIC16Fxxx and xxxA parts are perfectly code-compatible, but I'm not sure.