RE: RE: Obsluha vnějšího přerušení u PIC
Radek Benedikt
benedikt na login.cz
Pondělí Říjen 25 10:27:50 CEST 2010
Jinak pro ty co se obcas venuji kontaktum a jejich odruseni na urovni
programu tak doporucuji podivat se po tematu nazyvanem "vertical counters".
Dost jsem na to ziral (a na to kolik mi je me jen tak nic nepřekvapí) a
ohledne osetreni zakmitu kontaktu u vice nez jednoho kontaktu najednou jsem
zatím elegantnejsi reseni nevidel.
Pro PIC je to napr. na
http://www.dattalo.com/technical/software/pic/vertcnt.html
A abych jen nelákal a protože je mi bližší I8051 tak to v mém provedení
vypadá takto: (a pokud to chcete zdrbat tak prosím o změnu Předmětu zprávy)
;
; Debouncing with vertical counters - 4 stage - 16 count
;
;R2 in - bouncy_source , out - changed bits
;R3 debounced_source
; Based on an original PIC idea by Scott Dattalo,
; Steve M Taylor and improved by Hans van Pelt.
;R7 vertical_counter_a = 0;
;R6 vertical_counter_b = 0;
;R5 vertical_counter_c = 0;
;R4 vertical_counter_d = 0;
fast_debouce_4_stage_counter:
;;Increment the vertical counter.
; vertical_counter_d = vertical_counter_d ^ ( (vertical_counter_a &
vertical_counter_b) & vertical_counter_c );
mov a,r7
anl a,r6
anl a,r5
xrl a,r4
mov r4,a
; vertical_counter_c = vertical_counter_c ^ (vertical_counter_a &
vertical_counter_b);
mov a,r7
anl a,r6
xrl a,r5
mov r5,a
; vertical_counter_b = vertical_counter_b ^ vertical_counter_a;
mov a,r7
xrl a,r6
mov r6,a
; vertical_counter_a = ~vertical_counter_a;
mov a,r7
cpl a
mov r7,a
;;Clear counters for unchanged inputs.
; t = bouncy_source ^ debounced_source;
mov a,r2
xrl a,r3
mov r2,a
; vertical_counter_a = vertical_counter_a & t;
;mov a,r2
anl a,r7
mov r7,a
; vertical_counter_b = vertical_counter_b & t;
mov a,r2
anl a,r6
mov r6,a
; vertical_counter_c = vertical_counter_c & t;
mov a,r2
anl a,r5
mov r5,a
; vertical_counter_d = vertical_counter_d & t;
mov a,r2
anl a,r4
mov r4,a
; t = ~t;
mov a,r2
cpl a
mov r2,a
; t = t | vertical_counter_a;
;mov a,r2
orl a,r7
mov r7,a
; t = t | vertical_counter_b;
mov a,r2
orl a,r6
mov r6,a
; t = t | vertical_counter_c;
mov a,r2
orl a,r5
mov r5,a
; t = t | vertical_counter_d;
mov a,r2
orl a,r4
mov r4,a
; t = ~t;
mov a,r2
cpl a
mov r2,a
; debounced_source = debounced_source ^ t;
xrl a,r3
mov r3,a
ret
Radek
Další informace o konferenci Hw-list