Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Test0 ;used on error to provide external warning
; movlb 2 ;not used in simulation |B2
; BSF LED ; |B2
; DelayCy (25*msecs)
; BCF LED ; |B2
; DelayCY (25*msecs)
;setup serial port
MOVLB 4 ;SPI controls in Bank4 |B4
MOVLW b'00000001' ;
MOVWF SSPCON1 ;CKP=0,master clk=Fosc/16
;04.25.15 tried all 3 settings for <3,0>, Fosc/64 did not work, others did,
;hung up on waiting for the BF flag bit. Fosc/16 should work wtih all Fosc
;up to 32 MHz. AS5048 internal clock is ca. 5 MHz. ˜˜
CLRF SSPSTAT ;CKE=0 |B4
GetSPI
MOVLB 4 ; |B4
BSF SSPCON1,SSPEN ;enables serial port |B4
MOVLB 2 ; |B2
BCF CSn ;!CS |B2
MOVLB 4 ; |B4
; MOVLW 0xFF ;alternative to zeros |B4
; MOVWF SSPBUF ; |B4
CLRF SSPBUF ;alternative |B4
GetBUFF
;NB:Polling SSPSTAT,BF seems to work as well as polling PIR1,SSPIF and
;doesn't require bank switching.
btfss SSPSTAT,BF
goto $-1
movf SSPBUF,w
movwf SPI_H
CLRF SSPBUF
btfss SSPSTAT,BF
goto $-1
movf SSPBUF,w
movwf SPI_L
BCF SSPCON1,SSPEN ;disable SPI port
movlb 2 ; |B2
bsf CSn ;set !SS(CSn)high
; NOP ;debugging
ErrTest
BTFSS SPI_H,7
GOTO Test0
BTFSC SPI_H,6
GOTO Test0
BCF SPI_H,7
; DelayCy (300*msecs)
; DelayCy (300*msecs)
goto GetSPI