12.07.2015 Views

Electromechanical Timer Replacement - 320Volt

Electromechanical Timer Replacement - 320Volt

Electromechanical Timer Replacement - 320Volt

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Electromechanical</strong> <strong>Timer</strong> <strong>Replacement</strong>Counter2ACounter2bsf flags,OUTON ;set timer output on flagbtfss flags,RSTON ;is reset input active?goto seqEnd ;if not, go to seqEndcall MoveP1ToTgt ;initialize target counter valuedecf modest ;move back to mode state 1goto seqEnd ;go to seqEndbsf flags,OUTON ;set timer output on flagbtfsc flags,EDGON ;have we detected an active input edge?goto ACounter2a ;yes we have - go to ACounter2abtfss flags,RSTON ;is reset input active?goto seqEnd ;if not, go to seqEndcall MoveP1ToTgt ;initialize target counter valuedecf modest ;move back to mode state 1goto seqEnd ;go to seqEnd; auto reset handler (make sure configuration program does not allow terminal; count value less than 2)ACounter2abcf flags,OUTON ;clear timer output on flagcall MoveP1ToTgt ;initialize target countercall DecrTgt ;decrement target counterdecf modest ;move back to mode state 1goto seqEnd ;go to seqEnd;********************;* Start of program *;********************start movlw 11001111b ;disable wake-up on GPIO pin change, disable weak; pullups, use internal clock for RTCC (positive edge),option ; assign prescaler to WDT, set prescaler to 128movlw GPTRIS ;set GPIOtris GPIO ; TRIS registermovf RTCC,w ;initializemovwf oldRTCC ; oldRTCC valuecall InitRollOver ;initialize rollover counterclrf tgtL ;initializeclrf tgtH ; target count registermovlw DBNCTM ;initializemovwf dbncTmr ; debounce timerclrf inDbnc ;set initial state of timer input debounce; state machineclrf rstDbnc ;set initial state of reset input debouce; state machineclrf flags ;clear flags registerclrf modest ;clear timer mode state;read the timer configuration from the EEPROM and copy it to the;block of file registers used to hold the configuration datareadEEmovlw 6movwf bcount ;set number of bytes to read as 6movlw mode ;set FSR to point to 1st address intomovwf FSR ; configuration memory blockcall bStart ;generate start bitmovlw 10100000b ;set slave address and write mode andmovwf txbuf ; copy into transmit buffercall tx ; and send itmovlw 0 ;copy read start addressmovwf txbuf ; into transmit buffercall tx ; and send itcall bStart ;generate start bitmovlw 10100001b ;get slave address and read modemovwf txbuf ;into transmit bufferDS40160A/1_005B-page 20© 1997 Microchip Technology Inc.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!