Truncated match.
PICList
Thread
'I2C Slave-transmit routine problem'
1999\11\10@055546
by
Paolo Marras
|
Hi and thenks for your attention,
This is my interrupt service routine (except for push and pop procedure):
btfss PIR1,3 ; SSPIF
goto EXIT
;--------------------------------------------------------------------
; Interrupt service routine
; I2C
;--------------------------------------------------------------------
service_int
bsf STATUS,RP0 ; Banck 1
btfss SSPSTAT,5 ; = 0 last byte -->ADDR
goto Access ;
bcf STATUS,RP0 ; Bank 0
btfsc I2C_reg,TR_RC ; my SSPSTAT,5 RAM copy
goto rd_dat ; Master red data
goto wr_dat ; Master wrote data
rd_dat
movf DATAO_flag,W ; load data to transmit(SLAVE-TRANSMIT)
movwf SSPBUF
bsf SSPCON,CKP ;enable CLK
goto IntOut ; Exit
wr_dat
movf SSPBUF,W ;Load data in W (e reset BF)
movwf DATAI ; dato stored in buffer DATAI
goto run_DATAI ; Stores in proper way the data
Access
btfsc SSPSTAT,2 ; if =1 SLAVE-TRANSMIT =0 SLAVE-RECEIVE
goto rd_adr ; follow Master read-access
(SLAVE-TRANSMIT)
goto wr_adr ; follow Master write-access
(SLAVE-RECEIVE)
wr_adr
bcf STATUS,RP0 ; Bank 0
bcf I2C_reg,TR_RC ; copy R/W_ bit in I2C_reg (=0
SLAVE-RECEIVE)
movf SSPBUF,W ; read SSPBUF e reset BF
goto IntOut ; Exit without storing data
rd_adr
bcf STATUS,RP0 ; Bank 0
bsf I2C_reg,TR_RC ; copy R/W_ bit in I2C_reg (=1
SLAVE-TRANSMIT)
movf DATAO_stato,W ; load data read for transmission
(SLAVE-TRANSMIT)
movwf SSPBUF
bsf SSPCON,CKP ;enable CLK
goto IntOut ; Exit
IntOut
bcf PIR1,3 ; erases SSP flag interrupt
bsf STATUS,RP0 ; Bank 1
bsf PIE1,3 ; Re-enable SSP interrupt
bcf STATUS,RP0 ; Bank 0
Main program
........
movlw B'00110110' ; Interrupt ogni Byte
movwf SSPCON
movlw B'00011000' ; RC3,RC4 tristate per SSP
movwf TRISC ;
bsf STATUS,RP0 ; bank 1
movlw B'00001000'
movwf PIE1
movlw B'10100100' ; ADDRESS of this device
movwf SSPADD
bcf STATUS,RP0 ; bank 0
movlw B'11000000'
movwf INTCON
Could you see some evident mistake?
When I try to read from PIC device a byte, It acks first address byte, but
after that it pulls down SCL, and it doesn't send the byte, although I have
enabled the serial clock setting CLK bit in SSPCON.
Then I need to reset MCU to restart I2C comunication.
Thanks
Paolo Marras
AIRLAB (Artificial Intelligence and Robotics LAB)
Electronics and Information department
Politecnico of Milan
More... (looser matching)
- Last day of these posts
- In 1999
, 2000 only
- Today
- New search...