Upload

Loading...

Quick look at I2C system I've been programming, sample subroutines in description

463 views

Loading...

Loading...

Loading...

Rating is available when the video has been rented.
This feature is not available right now. Please try again later.
Uploaded on Jul 15, 2011

This is just a quick look at the 18F14K50 PMOSFET board hooked up to the I2C expander board and an analog meter. I've been programming the various I2C components with subroutines like:

; I2C SUBROUTINES START HERE

; This routine waits for the last I2C operation to complete.
; It does this by polling the SSPIF flag in PIR1.
WaitMSSP btfss PIR1,SSPIF ; Check if done with I2C operation
goto $-2 ; I2C module is not ready yet
bcf PIR1,SSPIF ; I2C module is ready, clear flag.
Retlw 0 ; Done, Return 0

;**************************************************
; This routine sends the W register to SSPBUF, thus transmitting a byte.
Send_I2C_Byte
movwf SSPBUF ; Get value to send from W, put in SSPBUF
retlw 0 ; Done, Return 0

;**************************************************
;I2C Operation Failed code sequence - This will normally not happen,
; but if it does, a STOP is sent and goes back to try again
I2CFail
bsf SSPCON2,PEN ; Send STOP condition
call WaitMSSP ; Wait for I2C operation to complete
goto I2CWrite ; go back to beginning of write sequence

Loading...

When autoplay is enabled, a suggested video will automatically play next.

Up Next


to add this to Watch Later

Add to

Loading playlists...