12.07.2015 Views

EK-6 - 320Volt

EK-6 - 320Volt

EK-6 - 320Volt

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

198clrf ccpr1h ;Clear CCPR1H register199clrf ccpr1l ;Clear CCPR1L register200movlw b'00000101' ;CCP1M=0101(Capture)201movwf ccp1con ;Set CCP1CON register202bsf status,rp0 ;Change to Bank1203bsf pie1,ccp1ie ;CCP1 interruptin enable204bcf status,rp0 ;Change to Bank0205bcf pir1,ccp1if ;Clear CCP1 int flag206207 ;*** 40KHz pulse send ( 0.5 msec )208movlw d'20' ;Send-out pulse count209movwf s_count ;Set count210 s_loop211call pulse ;Call pulse send sub212decfsz s_count,f ;End ?213goto s_loop ;No. Continue214215 ;*** Get adjustment data216bsf adcon0,go ;Start A/D convert217 ad_check218btfsc adcon0,go ;A/D convert end ?219goto ad_check ;No. Again220movfw adresh ;Read ADRESH register221movwf s_adj ;Save converted data222223movlw d'5' ;Set rotate value224movwf s_adj_count ;Save rotate value225 ad_rotate226rrf s_adj,f ;Rotate right 1 bit227decfsz s_adj_count,f ;End ?228goto ad_rotate ;No. Continue229movfw s_adj ;Read rotated value230andlw b'00000111' ;Pick-up 3 bits231addlw d'54' ;(0 to 7) + 54 = 54 to 61232movwf s_adj ;Save adjustment data233234 ;*** Capture guard timer ( 1 milisecound )235movlw d'2' ;Set loop counter1236movwf g_time1 ;Save loop counter1237 g_loop1 movlw d'124' ;Set loop counter270

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

Saved successfully!

Ooh no, something went wrong!