-----Original Message----- From: Goovaerts To: PICLIST@MITVMA.MIT.EDU Date: 08 ݏ 1998 ., ݒ 19:42 Subject: Some questions !! >Hello, here are a few things I need to know : > >1. I want to use bits 3 and 4 of PORTC for SCL and SDA when working with > the I2C bus. I'm single master of this bus. My question is how to >initialise > this I2C-bus ?? I wrote some code. Does this code make any sense and > didn't I forget something ? > > The declaration of the variables looks like this : > >#DEFINE SCL PORTC,3 ;SCL PIN >#DEFINE SDA PORTC,4 ;SDA PIN > >INIT_I2C > > BCF STATUS , RP0 > CLRF PORTC > BSF STATUS , RP0 > MOVLW B'11100111' > MOVWF TRISC > > RELEASEBUS ; Don't know what this is and what >it does ? > ; Think it's a >macro. Think it makes SDA and > ; SCL high. > CLRF BUS_STATUS ; Signalisation FLAG !! > RETURN > >Is it so that you have to make SDA and SCL high to release the bus ?? > yes, this is a macro and SCL and SDA have to be high to release bus by making SCL and SDA pins inputs (TRISCx=1) >-------------------------------------- > >2. The following code that I found is a delay for 4.7 us : > >Delay47uSec > movlw ((_47uS_Delay-8)/3 + 1) >DlyK > movwf DelayCount > decfsz DelayCount > goto $-1 > return > >How does it work ? >What is _47uS_Delay ? It's probably defined somewhere else !! > >goto $-1 --> a loop ?? > _47uS_Delay is constant defined somewhere with #define >-------------------------------------- > >3. Slaves are allowed : Clock stretching ?? > >But when you have fast slaves, you don't have to implement this >in your software. How do I know I have to implement it or not ? >The I2C bus I'm working with is one inside a SONY TV. They >told me that the I2C it uses, is not the fast on (400k ??) If you implement it and have fast slaves - don't worry, but if you do not implement it and have fast slaves - you may have a problems ivan cenov