another way is to filter the input with a software routine
Code:
reeds var byte
reeds_flg var byte
reed_1_active var reeds_flg.0
reed_2_active var reeds_flg.1
reed_3_active var reeds_flg.2
reed_cnt var byte[3]
reed var byte
define reed_threshold 64
chk_reeds:
reeds=portc & $70 ;c4 c5 c6 active low
if reeds < 112 then
reeds=reeds >> 4
for reed = 0 to 2
if ! reeds.0 then
reed_cnt[reed]=reed_cnt[reed]+1
if reed_cnt[reed]> reed_threshold then reeds_flg.0[reed]=1
else
reed_cnt[reed]=0
endif
reeds=reeds>>1
next
endif
return
if you call the chk_reeds subroutine regularly (must be regular) say in this case 100 times per second, then if a reed input is consistently low for 64 (counts in a row the reed_threshold) then the reed_x_active flag will be set.
Bookmarks