Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int Timer;
- int State;
- enum(No_State=0, Init_State, Wait_State, Delay_State, Off_State);
- #define TIMR0_TICK 10ms
- #define INIT_DELAY=1*60/(64*256*1us)
- #define Delay_2min=4*60/TMR0_TICK
- #define Delay_4min=4*60/TMR0_TICK
- //---------------------------------------------------------------------------------------------
- main()
- {
- State=NoState;
- Init
- Loop:
- goto Loop;
- }
- //---------------------------------------------------------------------------------------------
- Interrupt()
- {
- if ( INTF ) { // 100Hz mains edge interrupt
- INTF=0;
- INTEDG=!INTEDG; // toggle int edge
- switch ( State )
- {
- No_State:
- TMR0=0; // set up 16ms delay
- Timer=INIT_DELAY;
- State++; // -> Init_State
- break;
- Init_State: // delay INIT_DELAY
- TMR0=0;
- if ( (--Timer) == 0 )
- State++; // -> Wait_State
- break;
- Wait_State: // reset 16ms timer
- TMR0=0;
- break;
- Delay_State:
- Off_State:
- break;
- }
- };
- if ( TMR0IF ) { // 16/10ms timer interrupt
- TMR0IF=0;
- switch ( State )
- {
- No_State:
- Init_State:
- break;
- Wait_State: // mains timeout (16ms)
- SSR=On;
- if ( OPT == 1 )
- Timer=Delay_4min;
- else
- Timer=Delay_2min;
- State++; // -> Delay_State
- break;
- Delay_State: // delay Delay_Xmin
- TMR0=TMR0_TICK; // 10ms
- if ( (--Timer) == 0 )
- {
- SSR=Off;
- State++; // -> Off_State
- }
- break;
- Off_State:
- break;
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement