> Hi Olin > Spoke to you before. > Lurker on the piclist. > Passing along a nice debounce routine developped by one of my > students(Greg Deshais) > As you can see it has no time delays so it is real fast. > Basically it doesn' resolve the switch condition until it reads 100 > ons or offs. > Would really enjoy hearing your comments and if you deem it > worthwhile you may post it on the list > _Debounce4 > movlw 0x64 > movwf countOn > movwf countOff > btfsc PORTA,4 > decfsz countOn,f > goto $ + 0x02 > goto A4On > decfsz countOff,f > goto $ - 0x05 > A4Off > bcf aFlag,4 > goto $ + 0x02 > A4On > bsf aFlag,4 > retlw 0x00 > regards > Ollie Wallock There was absolutely no reason this needed to be a private message to me. Getting feedback on a small section of code like this well within what the PIClist is for. If you are too chicken to have 2000 people pick apart your code then my only comment is "If you can't stand the heat, you don't belong in the kitchen". As for the code itself, I am dissappointed that a professor would even accept something like this from a student. I would refuse to look at it until it was properly documented and free of other blatant problems like irresponsible use of relative GOTOs. Greg nees to learn that documentation is of the utmost importance, and it's your job to make sure he does. The largest long term cost of software is debugging and maintainence, not the original coding. There are certainly cases, especially in small resource-limited systems, where code space and execution speed are important. If I had to pick however, most of the time I'd rather see 20 words of well documented easy to follow brute force code than 15 words of obtuse cute trick code to accomplish the same thing. Even though you accept this kind of mess, I do not. I encourage everyone on the PIC list not to comment on the algorithm itself until it is properly cleaned up and presentable, since you need to learn this lesson as badly as Greg does. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics