- fchao-Sinus-Wechselrichter AliExpress         
Ergebnis 1 bis 3 von 3

Thema: I2C: Fehlerhandling

Baum-Darstellung

Vorheriger Beitrag Vorheriger Beitrag   Nächster Beitrag Nächster Beitrag
  1. #1
    Erfahrener Benutzer Roboter-Spezialist Avatar von schorsch_76
    Registriert seit
    25.03.2012
    Ort
    Kurz vor Neuschwanstein
    Alter
    47
    Beiträge
    456

    I2C: Fehlerhandling

    Hallo Kollegen,

    kleine Frage: Wenn ich versuche mit einem I2C Slave zu sprechen und es kommt bsp. anstatt eines mt_data_ack ein mt_data_nack, hab ich ja ein Problem. Wie bringe ich den Bus dann wieder in einen Ok zustand? Muss ich einfach eine Stop Condition senden und es später nochmal probieren?

    PseudoCode:
    Code:
           //  sent byte from the queue
            send_byte(data);
    
    .....
    
            // check if the data was accepted
            if(!is_answer_tw_mt_data_ack())
            {
                // data was declined, set a flag for the user
                send_stop_condition();
                m_error_code = rx_no_answer_tw_mt_data_ack;
                return;
            }
    Ist das die richtige Methode den Atmega I2C Master wieder in einen guten Zustand zu bringen?

    Edit: Das hab ich daszu im Datasheet des Atmega168 gefunden auf Seite 219
    7. The application software should now examine the value of TWSR, to make sure that the
    data packet was successfully transmitted, and that the value of the ACK bit was as
    expected. If TWSR indicates otherwise, the application software might take some special
    action, like calling an error routine. Assuming that the status code is as expected, the
    application must write a specific value to TWCR, instructing the TWI hardware to transmit
    a STOP condition. Which value to write is described later on. However, it is important that
    the TWINT bit is set in the value written. Writing a one to TWINT clears the flag. The TWI
    will not start any operation as long as the TWINT bit in TWCR is set. Immediately after
    the application has cleared TWINT, the TWI will initiate transmission of the STOP condition.
    Note that TWINT is NOT set after a STOP condition has been sent.
    Geändert von schorsch_76 (04.09.2014 um 09:58 Uhr)

Ähnliche Themen

  1. [ERLEDIGT] Atmega: Prozessorauslastung feststellen und Fehlerhandling
    Von schorsch_76 im Forum C - Programmierung (GCC u.a.)
    Antworten: 11
    Letzter Beitrag: 14.10.2014, 20:18
  2. Problem mit I2C Sensor DRMOD-I2C-RVI
    Von muerzi im Forum Sensoren / Sensorik
    Antworten: 23
    Letzter Beitrag: 22.02.2010, 18:29
  3. Antworten: 2
    Letzter Beitrag: 10.08.2006, 12:18
  4. Problem: Zwei MEGA8 via I2C-Bus koppeln (mit I2C-slave-Lib)
    Von Ulfens im Forum Basic-Programmierung (Bascom-Compiler)
    Antworten: 4
    Letzter Beitrag: 11.01.2006, 15:25
  5. *I2C* maximale eingänge per i2c auf 8 digitale Pins
    Von Christian Sturm im Forum Elektronik
    Antworten: 9
    Letzter Beitrag: 22.06.2004, 19:44

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

MultiPlus Wechselrichter Insel und Nulleinspeisung Conrad