Here's what I've got so far... for the "slave" pics anyhow.
Critiques are definitely welcome!
16F688 w/20Mhz
Thanks again guys,Code:INCLUDE "DT_INTS-14-MOD.bas" INCLUDE "ReEnterPBP.bas" 'Clock setup Define OSC 20 'Pin setups ANSEL = %00000000 'No analog input TRISA = %00000111 'PortA: TRISA = %00XXXXXX TRISC = %00000000 'PortC: TRISC = %00XXXXXX 'Usart setups DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1 DEFINE HSER_CLROERR 1 ' Clear overflow automatically DEFINE HSER_SPBRG 86 ' 57600 Baud @ SPBRGH = 0 BAUDCTL.3 = 1 ' Enable 16 bit baudrate generator '---------------------------------------------------------------------------- MaxCount con 21600 BtnZeroCount var PORTA.0 APin var PORTA.1 BPin var PORTA.2 AOld var byte BOld var byte CurCount var word ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler RAC_INT, _ABInt, PBP, yes endm INT_CREATE ; Creates the interrupt processor INT_ENABLE RAC_INT ; Enable RA change interrupt ENDASM curcount = 0 Start: if btnzerocount = 0 then 'btnzerocount (A.0) has pullup res curcount = 0 endif aold = apin bold = bpin hserout ["$", dec5 curcount] goto start ABInt: '\\\ A caused the interrupt /// IF apin != aold THEN 'APin IS NOT equal to AOld IF apin != bpin THEN 'If A and B are different, GOTO CW 'it was clockwise rotation ELSE 'Otherwise, GOTO CCW 'it was counter-clockwise rotation ENDIF ENDIF '\\\ B caused the interrupt /// IF Bpin != Bold THEN 'BPin IS NOT equal to BOld IF apin == bpin THEN 'If A and B are the same, GOTO CW 'it was clockwise rotation ELSE 'Otherwise, GOTO CCW 'it was counter-clockwise rotation ENDIF ENDIF CW: ' -1 if curcount > 0 then curcount = curcount -1 else curcount = MaxCount endif @ INT_RETURN CCW: ' +1 if curcount < maxcount then curcount = curcount +1 else curcount = 0 endif @ INT_RETURN
Chris







Bookmarks