i tried writing some code
;expected result is a high on portC,0 when
;start bit is detected.
;**********************************************************
__config _LVP_OFF & _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF & _BODEN_OFF & _DEBUG_OFF
include "p16f877.inc"
STORAGE1 set 0x20
INNERWHEEL set 0x21
OUTERWHEEL set 0x22
COUNTER set 0x23
; Start at the reset vector
org 0x000
goto Start
org 0x004
Interrupt
retfie
Start
bsf STATUS,RP0 ;bank 1
bcf STATUS,RP1
movlw H'FF'
movwf TRISA ;porta [0] input
movlw H'00'
movwf TRISC ;portc [7-0] outputs
movlw H'00'
movwf TRISB ;portc [7-0] outputs
movlw H'07'
movwf OPTION_REG ;set prescaler
movlw H'06'
movwf ADCON1 ;set input bits to be digital
bcf STATUS,RP0 ;bank 0
clrf PORTC
Main
WaitS btfss PORTA,0 ;if high, then skip (break out
;of loop)
goto WaitS
clrf TMR0
WaitT btfsc PORTA,0 ;wait until a low pulse is
;obtained.
goto WaitT
movf TMR0,W ;TMR0 value is in W
sublw .35 ;W = .35 - W
btfss STATUS,CARRY ;if W> .35 then carry bit will
;be 0
bsf PORTC,0
goto Main
end
it should detect a .35 TMR0 cycle long high pulse (or longer) from portA, bit 0,... but it doesn't work.... i don't know why, but nothing appears in PORTC bit 0..... can anyone tell me why?
;expected result is a high on portC,0 when
;start bit is detected.
;**********************************************************
__config _LVP_OFF & _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF & _BODEN_OFF & _DEBUG_OFF
include "p16f877.inc"
STORAGE1 set 0x20
INNERWHEEL set 0x21
OUTERWHEEL set 0x22
COUNTER set 0x23
; Start at the reset vector
org 0x000
goto Start
org 0x004
Interrupt
retfie
Start
bsf STATUS,RP0 ;bank 1
bcf STATUS,RP1
movlw H'FF'
movwf TRISA ;porta [0] input
movlw H'00'
movwf TRISC ;portc [7-0] outputs
movlw H'00'
movwf TRISB ;portc [7-0] outputs
movlw H'07'
movwf OPTION_REG ;set prescaler
movlw H'06'
movwf ADCON1 ;set input bits to be digital
bcf STATUS,RP0 ;bank 0
clrf PORTC
Main
WaitS btfss PORTA,0 ;if high, then skip (break out
;of loop)
goto WaitS
clrf TMR0
WaitT btfsc PORTA,0 ;wait until a low pulse is
;obtained.
goto WaitT
movf TMR0,W ;TMR0 value is in W
sublw .35 ;W = .35 - W
btfss STATUS,CARRY ;if W> .35 then carry bit will
;be 0
bsf PORTC,0
goto Main
end
it should detect a .35 TMR0 cycle long high pulse (or longer) from portA, bit 0,... but it doesn't work.... i don't know why, but nothing appears in PORTC bit 0..... can anyone tell me why?