Code:
'****************************************************************
'* Name : are.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2013 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 1/17/2013 *
'* Version : 1.0 *
'* Notes : spi read of bourne rotary encoder *
'* : 16f72 *
'****************************************************************
#CONFIG
cfg = _HS_OSC
cfg&= _WDT_ON
cfg&= _PWRTE_ON
cfg&= _CP_OFF
cfg&= _BOREN_ON
__CONFIG cfg
#ENDCONFIG
include "dt_ints-14.bas"
include "REENTERPBP.bas"
asm
INT_LIST macro
INT_HANDLER SSP_INT, _spo, asm,YES
endm
INT_CREATE
INT_ENABLE SSP_INT
ENDASM
wsave VAR BYTE $20 SYSTEM ' location for W if in bank0
;wsave VAR BYTE $70 SYSTEM ' alternate save location for W
' if using $70, comment wsave1-3
' --- IF any of these three lines cause an error ?? ------------------------
' Comment them out to fix the problem ----
' -- Which variables are needed, depends on the Chip you are using --
wsave1 VAR BYTE $A0 SYSTEM ' location for W if in bank1
'wsave2 VAR BYTE $120 SYSTEM ' location for W if in bank2
'Wsave3 VAR BYTE $1A0 SYSTEM ' location for W if in bank3
' --------------------------------------------------------------------------
pos var byte
old_pos var byte
mint var portc.0
tmp var byte
DEFINE OSC 20
adcon1=6
trisc=%11011110
option_reg.7=0
mint=1
SSPSTAT.6=1
sspcon.5=1
sspcon.4=0
sspcon.2=1
pir1.3=0
PIE1.3=1
INTCON=$c0
gosub getp
old_pos=pos
pause 2000
MAIN
gosub getp
if (pos != old_pos )&& (mint) then
old_pos=pos
sspbuf=pos;
mint=0;
endif
GOTO MAIN
GETP:
tmp= (porta&$f)|((portb&$f)<<4)
Lookdown tmp,[$7F,$3F,$3E,$3A,$38,$B8,$98,$18,$08,$48,$49,$4D,$4F,$0F,$2F,$AF,$BF,$9F,$1F,$1D,$1C,$5C,$4C,$0C,$04,$24,$A4,$A6,$A7,$87,$97,$D7,$DF,$CF,$8F,$8E,$0E,$2E,$26,$06_
,$02,$12,$52,$53,$D3,$C3,$CB,$EB,$EF,$E7,$C7,$47,$07,$17,$13,$03,$01,$09,$29,$A9,$E9,$E1,$E5,$F5,$F7,$F3,$E3,$A3,$83,$8B,$89,$81,$80,$84,$94,$D4,$F4,$F0,$F2,$FA,$FB,$F9,$F1,$D1,_
$C1,$C5,$C4,$C0,$40,$42,$4A,$6A,$7A,$78,$79,$7D,$FD,$FC,$F8,$E8,$E0,$E2,$62,$60,$20,$21,$25,$35,$3D,$3C,$BC,$BE,$FE,$7E,$7C,$74,$70,$71,$31,$30,$10,$90,$92,$9A,$9E,$1E,$5E,$5F],Pos
return
spo:
mint=1;
pir1.3=0
@ INT_RETURN
Bookmarks