Hallo izaseba,

danke für Deine ausführliche Antwort. Nachdem Dein Code ja gut läuft: kannst Du mir die ganze Assembler-Source für Deinen Slave zur Verfügung stellen? Das wäre super nett.

Ich habe den Autor des Original-Codes, den s.o. oben eingestellt hat, ausfindig gemacht, es ist Piotr Piatek [piotr433@pisi.com.pl], der Code stammt orginal von dieser Internet Seite:

http://www.pisi.com.pl/piotr433/pcf_12.asm

Ich habe folgendes Statement von Piotr erhalten:

Hello Dirk,

On Mon, 26 Nov 2007 15:18:24 +0100, you wrote:

>Now the surprise: your code works properly and the address and command
>byte are well received by the slave, as long as the check for a stop
>condition is left as comment as in your original file. However, when
>removing the comment signs and thereby activating the check of a stop
>condition in the wait loops for USI overflow, the I2C communication is
>always stopped. I watched the signals on osci. I could not find a stop
>condition except at the end of transmission.
>
>Do you have an explanation?

I experienced the same behaviour, but couldn't explain it. The USIPF bit seemed to be permanently set regardless of the bus state. An attempt to clear it by software failed as well. I don't know whether this was a bug in the silicon, or did I misunderstand the datasheet.

>Obviously, you had a reason to comment the check for stop condition and
>not use it in the real code?

It was only a quick fix to make the code work. Eventually I decided to abandon the USI at all, and to do everything in software.

Later I found a similar I2C slave implementation written by someone else (in the attachment, not tested). Please note that it doesn't check for stop condition, either.

Best regards

Piotr
Ich vermute nun, dass die Stop-Condition-Flag USIPF in dem Code versehentlich jeweils in folgender Anweisung gesetzt wird, da das Bit USIPF (in USISR) laut Datenbuch nur durch Beschreiben mit einer 1 gelöscht wird (also möglicherweise durch Schreiben einer 0 dann auch gesetzt wird?):

  • ldi Temp1,(1<<USIOIF)+0x00 ;10 SCL edges
    out USISR,Temp1


Was meint ihr? Ich werd es heute abend ausprobieren.

Gruß, uffi.[/b]