On Wed, 7 Jan 2004 10:11:53 -0000, Alan B. Pearce wrote on Re: [PIC:] Pic as an i2c slave: >>I still have to fully understand why CKP should be set at >>that point, but of course I'll believe the gurus... >> >>A code comment here says that we should never get to that >>state; having to add that instruction at that place implies >>that for the whole thing to consistantly succeed afterwards >>it first has to fail once and reach this uncontrolled >>state... Strange... > >Umm, not sure about never getting there. Here is what I am referring to, copied ans pasted from AN734a.pdf: State5: movlw b=9200101000=92; A NACK was received when transmitting xorwf Temp,W ; data back from the master. Slave logic btfss STATUS,Z ; is reset in this case. R_W =3D 0, D_A =3D 1 goto I2CErr ; and BF =3D 0 return ; If we aren=92t in State5,=20 ; then something is wrong. I2CErr: nop banksel PORTB ; Something went wrong! Set LED bsf PORTB,7 ; and loop forever. WDT will reset goto $ ; device, if enabled. return This comment "something went wrong" seems to imply that the current state, that leads to i2cErr has no meaning there and in fact should never happen; it appears to be confirmed by the pathetic attempt to have the watchdog reboot the PIC by executing a goto $ instruction... >I haven't refreshed myself properly >about how the code works, but from the quick glance through on writing = the >previous message, it will get there if the master sends back a NAK when = the >slave is sending data to the master. The result is that there is no = release >of the clock by the slave for the master to do the next message - i.e. = the >slave is doing a permanent clock stretch. Is this what you see on the = scope >when your system gives up? This may be the case and I'll have to investigate into it, I will try to borrow a storage oscilloscope from my job. >Will organise the module for you, I have to go turn on a machine on = another >floor to get the most current version. Many thanks again, Alan * Xrobert.soubie@free.frX (veuillez supprimer les "X") * http://www.astrosurf.com/soubie * Au royaume des aveugles, les borgnes sont mal vus... - P.Dac -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads