November 24, 2024, 02:23:37 PM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


Strange behavior from Prop-1 program

Started by JackMan, March 16, 2013, 07:58:36 AM

Previous topic - Next topic

JackMan

I'm playing around with a program that uses 2 buttons to set the timing of 500ms pulses on an output and writes those to eeprom. It also writes a button programmed time for post delay. There is a 10s window after power-up to enter the set-up mode, otherwise the program preceeds as normal.  This program works perfectly after the initial button entries, it will retain all of the button settings and play them back everytime the program is triggered, just as it should. The strange part is, if I re-enter the set-up mode a second time, the program hangs and does some weird things like outputs going high that should not be on. When it does this, if I power down and back up (reset) it will run the initial settings perfectly again but it will not allow me to re-enter the set-up mode, it hangs. I'm sure I am missing something but I have no idea what.

JackMan

OK, found the culprit. I had something defined as a constant that needed to be a variable.  ::)

JonnyMac

I was just looking at your program, too. I suggest that you create default values in EEPROM like this:

' -----[ User Data ]-------------------------------------------------------

' Duration Timer

EEPROM (0)                                      ' address 0

' Pulses

EEPROM (0)                                      ' address 1

' Post Delay

EEPROM (0)                                      ' address 2


By doing this you can load default values into the EEPROM and -- this is IMPORTANT -- you can ensure that your program tokens and EEPROM data are not colliding using the Memory Map. You have to be very careful with WRITE, especially with a program this long. If you write over active program space you will get unexpected results. The BS1 does not use byte-sized tokens, they are compressed as required so you cannot use WRITE to modify your program, you can only use it to modify free EEPROM space.
Jon McPhalen
EFX-TEK Hollywood Office

JackMan

Thanks Jon. Would I enter all 3 EEPROM defaults as "0"?

JonnyMac

That's the thing, you can enter any [byte] value you want -- so put what the recommended defaults should be for a "normal" situation. Then you're able to bypass the setup if the built-in defaults are useful for what you're doing.
Jon McPhalen
EFX-TEK Hollywood Office

JackMan

Well, I must have just gotten lucky yesterday with how the data was arranged when the program downloaded. I reloaded the same program this morning and I'm having the same issue again. No big deal, I'm just playing around with this anyway.

JonnyMac

I was worried about your program corrupting itself as you didn't seem to be controlling the locations for WRITE (which should start at address 0 of the EEPROM and increment from there). At any rate, I always use the EEPROM keyword to pre-save values -- this also allows the compiler to generate an error when your program code encroaches on the space allocated for WRITE.
Jon McPhalen
EFX-TEK Hollywood Office