Edge Detection
Hi,
I need to detect an edge of a signal (+ or -). I have tried to use the example in the manual but it doesn't seem to work. Anyone knows how please let me know. In the main program, I would like to set rc.0 "high" when a positive edge is detected.
Thanks
Hai
start
··MOV·M,#$0F····;Set up MODE register.
··MOV·!RB, #$FF···;Set $00 make RB all Inputs.
··MOV·!RC, #$00···;Set $00 make RC all Outputs.
··MOV·M,#$0E····;Set up MODE for PULL-UP configuration.
··MOV·!RB, #$00···;Set $00 make RB all inputs' Pullup.
··MOV·!RC, #$00···;Set $00 make RC all Outputs' Pullup.
;
··MOV·M,#$0A
··MOV·!RB, #$00···;Set $00 make +slope·detect at RB pins.
;
main
··MOV·M,#$09
··MOV·!RB,#$00
· JMP·main
I need to detect an edge of a signal (+ or -). I have tried to use the example in the manual but it doesn't seem to work. Anyone knows how please let me know. In the main program, I would like to set rc.0 "high" when a positive edge is detected.
Thanks
Hai
start
··MOV·M,#$0F····;Set up MODE register.
··MOV·!RB, #$FF···;Set $00 make RB all Inputs.
··MOV·!RC, #$00···;Set $00 make RC all Outputs.
··MOV·M,#$0E····;Set up MODE for PULL-UP configuration.
··MOV·!RB, #$00···;Set $00 make RB all inputs' Pullup.
··MOV·!RC, #$00···;Set $00 make RC all Outputs' Pullup.
;
··MOV·M,#$0A
··MOV·!RB, #$00···;Set $00 make +slope·detect at RB pins.
;
main
··MOV·M,#$09
··MOV·!RB,#$00
· JMP·main
Comments
So I'd try something like:
start
· MOV M,#$0F ;Set up MODE register.
· MOV !RB, #$FF ;Set $00 make RB all Inputs.
· MOV !RC, #$00 ;Set $00 make RC all Outputs.
· MOV M,#$0E ;Set up MODE for PULL-UP configuration.
· MOV !RB, #$00 ;Set $00 make RB all inputs' Pullup.
· MOV !RC, #$00 ;Set $00 make RC all Outputs' Pullup.
;
· MOV M,#$0A
· MOV !RB, #$00 ;Set $00 make +slope detect at RB pins.
;
· MOV M,#$09· ; Prepare to·use WKPND_B register
· MOV W,#$00· ; Assume all bits off initially
· MOV !RB,W····; Zero all edge detection bits
· NOP·········· ·· ; Might be needed ???
;
main
· MOV !RB,W ; This will put the register bits in W
· TEST W···· ; Is W zero ?
· SZ··········· ; Yes, then no edges detected, so skip SETB
· SETB RC.0· ; Edge detected so set RC.0
· JMP main
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"It is our choices, Harry, that show what we truly are, far more than our abilities."·Dumbledore from Harry Potter
www.iElectronicDesigns.com
Post Edited (Bean (Hitt Consulting)) : 10/24/2008 3:05:13 PM GMT
I tried the codes you suggest. What I expect to see is as soon as I send a + slope rb.0 for example, I should see a permanent "hi" signal on rc.0. The reality is I just saw a short hi pulse then rc.0 turns "lo" right away. Please advise.
Thanks
Hai
start
· MOV M,#$0F ;Set up MODE register.
· MOV !RB, #$FF ;Set $00 make RB all Inputs.
· MOV !RC, #$00 ;Set $00 make RC all Outputs.
· MOV M,#$0E ;Set up MODE for PULL-UP configuration.
· MOV !RB, #$00 ;Set $00 make RB all inputs' Pullup.
· MOV !RC, #$00 ;Set $00 make RC all Outputs' Pullup.
;
· MOV M,#$0A
· MOV !RB, #$00 ;Set $00 make +slope detect at RB pins.
;
· MOV M,#$09· ; Prepare to·use WKPND_B register
· MOV W,#$00· ; Assume all bits off initially
· MOV !RB,W····; Zero all edge detection bits
· NOP·········· ·· ; Might be needed ???
;
main
· MOV !RB,W ; This will put the register bits in W
· TEST W···· ; Is W zero ?
· SZ··········· ; Yes, then no edges detected, so skip SETB
· SETB RC.0· ; Edge detected so set RC.0
· JMP main
Bean