I apologize if I cast a doubt on the Select Case correct working.. I persisted a while with some tests and found my error being in the need to prepare the new text and display refresh flag at the moment of leaving the present state and moving to the following one.. Now the sequence is correct, and the flow and readability of the program been improved with Select Case, a subroutine for LCD refresh and a Function for the button pressed test. Attached a working version of this prime stage. Sorry having...
Thanks for yr answer.. I made additional tests. Your code for some reasons gives me errors, starting as soon as the row "Dim debug = 1".. And others.. I reduced my code to the bare minum of two states, and in this case it works( see test1.gcb attached). But as soon as more "case is" block get added, I find troubles. Therefore I decided to abandon the Select Case approach e moved to a series of "if state is.." and my code works fine. Finally, I improved the display refresh method and also the pushbutton...
Might it be possible that multiple if/then blocks nested whitin a Do-loop that contains a Select Case etc.. creates some reentrance prolems with this small uCtr?
Thanks for your answer, Evan.. However, I can't see the difference in respect to my code. It does'nt matter (for the moment) to add more button checks into the other states. The cycling was made only to begin the development, during the final version states may change on different criteria.. The problem is that this block here is completely ignored: (whitin State=1) if Start_Btn = 0 then wait 100 mS 'debounce if Start_Btn = 0 then Wait Until Start_Btn = 1 stato = 2 end If end if I found an error...
Hi there, I am preparing a little program for a new project in wich I use a simple program architecture with a State Machine. Checking the pressure of a button to ground on a pin, doing it in the main Do-Loop before entering the Select Case block of the State Machine, I can cycle trough 1 to 5 states without problem.. But if I want to check the pin condition WHITIN one of the states, in order to move from one state to another, the button pressure gets ignored.. I made several tests, but I am still...
Sorry, I realized immediately that it's not possible.. Just discard the last post.. Executing a DIM instruction will put to zero the flag anyway, and my problem is to check during the normal operations that if there is a power failure, the cpu must go in sleep, and preserve only WDT/RTC data and oscillators..
What happens when the Watchdog has reset from Sleep the CPU? The execution starts from the beginning of program like the one of a Master Reset, or it returns to the Do-Loop? I may leave the sleep instruction just before the do-loop starts in such case .. If the pwr_down variable in RAM is preserved during the Sleep (provided the battery backup is still powering the CPU), then the if pwr_down=15 then sleep put before the do-loop could be the solution. I'll give it a try. But still do not understand...
That's what I said I did in my previous post.. Down here is the flow of the program at present. The sleep instruction works only if put outside ISR and outside the main Do-Loop. Can't understand why. config & vars etc .. if I put SLEEP here, it works and gets executed .. Do forever ... other stuff to do forever... 'reset the Watchdog Timer ClrWDT 'if a flag of low voltage is set, put CPU to sleep if pow_down=15 then pow_down=0 sleep 'also here does not get executed end if loop sub Interrupt_Handler...