This is a multi-part message in MIME format. ------=_NextPart_000_00E9_01C63BBA.57F2BEC0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit I'm struggling to see why this code occassionally misses the first byte of a data stream, and would appreciate any insights and/or improvements to make the problem go away Master is an 18F452 (39.3216MHz), receiver is a 16F88 (4MHz). I2C speed is 100kHz, SCL and SDA have 1k pull-ups Attached is a typical occurence [address] [T or D] [data bytes] is sent from the Master. What happens is that the F88 recognises its address and Acks. It is then supposed to detect whether the character after the address is "T" (data following is for 3 time registers) or "D" (data following is for another use). The address is always Acked, but the next byte is sometimes ignored. It's as though the F88 has recognised its address, and therefore Acked, but then decides it didn't recognise it after all The double-blip on "marker" is at "header" is quite telling as to what the F88 is doing after the address byte As can be seen from the "marker" line in the top half ("Time not set"), program flow appears to go back to the loop around w_adata. The result of this is that when the program does get its drawers on and picks up the data, it's meaningless because one byte has been lost. For some reason the first of three time data bytes has been interpreted as the "T" In the lower half ("Time set"), the T character IS detected successfully and the data does end up in the time registers. Same as if it was D - data is stored correctly in the r_byte array and is usable. The "tick" is from an external 0.5Hz clock, and is timed to be well away from any I2C or RS232 comms, so I'm confident that is not the problem. The problem occurs at any stream length from 3 to 40 characters. The first byte after the T or D is missed, all others are picked up. Before and after reception, whether successful or not, SCL/SDA are high. I've looked at them with a high-speed analyser and see no noise or ringing. I have had trouble with I2C on the F88 before and would not be surprised if this is silicon cooties again Any ideas ? TIA ;================================================ ; Wait for I2C ;================================================ w_adata bank1 btfsc b_full ;address byte before data goto chk_addr ;something received bank0 bsf marker btfsc clock ;update time if a tick happened call update_time bcf marker goto w_adata ;else loop ;------------- chk_addr bank0 bcf led btfsc pir1,sspif ;test for address match goto header ;yes movfw sspbuf ;no movfw sspbuf bcf sspcon,sspov goto w_adata ;look for T or D as first character header bsf marker nop bcf marker nop bsf marker nop bcf marker bcf sspcon,sspov bcf pir1,sspif movfw sspbuf movfw sspbuf bank1 btfss b_full ;byte01 = D or T goto $-1 bank0 bsf marker bcf sspcon,sspov bcf pir1,sspif movfw sspbuf movwf temp ;hold D or T bcf marker bcf t_d ;default = data xorlw "T" ;test if "T", set time bnz set_dev ;not "T", is other data bsf t_d ;note as time set set_dt movlw tcntl ;store time in time registers movwf fsr goto data_pu set_dev movlw r_byte ;store data in buffer movwf fsr data_pu ...... pick up rest of data and rest of program =============================================== If you aren't part of the solution, you're part of the precipitate ------=_NextPart_000_00E9_01C63BBA.57F2BEC0 Content-Type: image/gif; name="notset_set.gif" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="notset_set.gif" R0lGODlhQwLzAIAAAAAAAP///ywAAAAAQwLzAEAC/oSPqcvtD6OctNqLs968+w+G4kiW5omm6sq2 7gvH8hwHjr3gOaMnvc9r/A5DYnB3VBQNy2bgSXwulUkq0noFVhHT5pb7NWa50ihUGGamAd4x2C3G yt9zulZZZuYf3fUUDVgXd0dYOGioltYGxxaI2MgmhfNnV2mZKIj5CJnJ+djH6HkJKTl544fKCNq5 mNn6eVSq6Qi7RnOLm6u7y9vr+8s7JKu3Z/ZLGYqnDDyB3EkL4bzpCHWmRxZZIs2Msa3hPZsCvnpd fnb+Y50LLsptwg5fES8foa7iZD6pX86zn/2Pjp8EctossOMwzp3ChQwbOnwIMSKfZxNH1ZtW8RCF /nQZOPbyeAGkQYynLF402TGOjoPfWEo8mQyGsJQoS2psRpKWS5G6eG7MuWUn0KAjVqrc6C8gwJU2 lCp9idMW1KlUq1q9ijWr1q1cu3r9CjZaD6dJ/5DN16+pMJdh27p9Czeu3Ll069q9izev3r18+/r9 Cziw4MGECxv+axZauMWMX1l0zLhdZMiSiSUqpniyolShihC8qVlV2sv2anXejFp06k2fJ5+zHG31 0MqhXWWmTJty69yyyZSSBJNV79rCixu3reo38NuZK+N+ztn08cfKMQ/nfTi79u3cDS3nZ60a2xMJ sZ1dCn7Y8u8y5kX9SS8+n/Ehc5QJeH+s9Wvh/vOs388MfeKMRFFV5d3l3kAEwsdgMN3Fxk2CD05I YYVyCVWTTZFBC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/ruCqEq0nOqoRYu0plioHzudd7q0 SWu03QG1q4pgmmq1V4u1mYmsydYSqMiJOeK1X1uLYduIIRe00+e0u+iwXamRPNmTGMmEZkaSLhkI RvleInmU3Si0KLuObnuR+9Rn7ciNG+klSFkUZ9uLhNt2Yvi2cPu3EBW4BMlmerslhmswiDuxiru3 PouNkmuOgCu3Fjm5mlu5eOtZftmCvuSD9ki6NLu4NBW6PlkFkZuRDGuQYWK58+ORCStO/8oVdku3 OBlPsiuQkBu7jju6TFa4puuyMqu6C/m7lOu6mytRxIuSaXa8fpu8CJO309tl0iu8t0iqXqmUV6l5 X2m+58t9b+K5vlsqcFMLv1PLm/FLv/WLbGQblrGZtfvLv/3rv/+bM7cKwAN0sfA4wCezlz34l/tl hwfcmJPmMIapsb7rwHLimJxmYd9UwRvMwR3swR8MwiEswiNMwiVswieMwimswivMwi3swi8MwzGM MgUAAAA7 ------=_NextPart_000_00E9_01C63BBA.57F2BEC0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist ------=_NextPart_000_00E9_01C63BBA.57F2BEC0--