USI: Unterschied zwischen den Versionen

Aus der Mikrocontroller.net Artikelsammlung, mit Beiträgen verschiedener Autoren (siehe Versionsgeschichte)
Wechseln zu: Navigation, Suche
KKeine Bearbeitungszusammenfassung
(Updated wrong link)
 
(7 dazwischenliegende Versionen von 5 Benutzern werden nicht angezeigt)
Zeile 9: Zeile 9:
* SPI
* SPI
* TWI / I2C  
* TWI / I2C  
* UART (AVR307)


Alternative Funktionen
Alternative Funktionen
Zeile 18: Zeile 19:
* Software Interrupt, kann durch Setzen in einem USI-Register ausgelöst werden  
* Software Interrupt, kann durch Setzen in einem USI-Register ausgelöst werden  
----
----
== USI als I2C/TWI Interface ==
== USI als I2C/TWI Interface ==


=== USI als I2C/TWI Slave (Epprom) ===
=== USI als I2C/TWI Slave (EEprom) ===


Die Biblitothek ermöglicht eine I2C/TWI Kommunikation über das USI
Die Biblitothek ermöglicht eine I2C/TWI Kommunikation über das USI
Zeile 36: Zeile 38:


* in "C"
* in "C"
* [http://www.jtronics.de/elektronik-avr/lib-i2ctwi-mit-usi-interface.html Bibliothek für I2C/TWI Slave mit USI in "C" von http://www.jtronics.de]
* [http://www.jtronics.de/avr-projekte.html Bibliothek für I2C/TWI Slave mit USI in "C" von http://www.jtronics.de]
* alle Beschreibungen findet man in der "usiTwiSlave.h" Datei.
* alle Beschreibungen findet man in der "usiTwiSlave.h" Datei.


Zeile 173: Zeile 175:


== Forum ==
== Forum ==
* [http://www.mikrocontroller.net/wikisoftware/index.php?title=USI&action=submit Attiny USI Slave Implementierung]
* [http://www.mikrocontroller.net/topic/38917 Attiny USI Slave Implementierung]
* [http://www.mikrocontroller.net/topic/23680 Erklärung zu ISP, I2C, TWI, SPI, ... ]
* [http://www.mikrocontroller.net/topic/23680 Erklärung zu ISP, I2C, TWI, SPI, ... ]


Zeile 181: Zeile 183:
* [http://www.atmel.com/dyn/resources/prod_documents/doc2561.pdf Atmel_AVR310 - Using the USI module as a I2C master ]
* [http://www.atmel.com/dyn/resources/prod_documents/doc2561.pdf Atmel_AVR310 - Using the USI module as a I2C master ]
* [http://www.atmel.com/dyn/resources/prod_documents/doc2560.pdf Atmel_AVR312 - Using the USI module as a I2C slave ]
* [http://www.atmel.com/dyn/resources/prod_documents/doc2560.pdf Atmel_AVR312 - Using the USI module as a I2C slave ]
* [http://www.jtronics.de/elektronik-avr/lib-i2ctwi-mit-usi-interface.html Bibliothek für I2C/TWI Slave mit USI in "C" von http://www.jtronics.de]
* [http://www.jtronics.de/avr-projekte/library-i2c-twi-slave-usi.html Bibliothek für I2C/TWI Slave mit USI in "C" von http://www.jtronics.de]


* [http://www.atmel.com/images/doc2582.pdf Atmel_AVR319 - Using the USI module for SPI communication]


----
----

Aktuelle Version vom 3. Juli 2016, 10:17 Uhr

Das Universal Serial Interface ist eine in manchen Mikrocontrollern vom Typ AVR (z. B. ATtiny26, ATtiny2313) verwendete serielle Schnittstelle. Es kann als TWI Interface, der Atmelvariante des I2C Busses, verwendet werden. Ebenso kann eine SPI Schnittstelle realisiert werden.

USI

USI (Universal Serial Interface) steht für Universelle serielle Schnittstelle, die vor allem in kleineren Atmel AVR Controllern, wie zB. beim ATTiny2313, aber auch in einigen ATMegas anzutreffen ist.

Wie der Name schon aussagt, handelt es sich dabei um ein All-in-One-Interface, das lediglich die Hardware zur seriellen Kommunikation enthält,jedoch praktisch keine Protokoll-Implementierung. Diese muss in der Software implementiert werden, je nachdem, welchen Interface-Typ man nutzen will.

Die Hauptfunktionen sind

  • SPI
  • TWI / I2C
  • UART (AVR307)

Alternative Funktionen Wenn die Schnittstelle nicht für die serielle Kommunikation verwendet wird, gibt es, wegen der universellen Auslegung, weitere Verwendungsmöglichkeiten:

  • Halb-Duplex Asynchrone Datenübertragung
  • 4-Bit Counter (0-15) mit verschiedenen Taktquellen
  • 12-Bit Timer/Counter in Verbindung mit Timer0
  • externer Interrupt, löst bei jeder Flanke aus
  • Software Interrupt, kann durch Setzen in einem USI-Register ausgelöst werden

USI als I2C/TWI Interface

USI als I2C/TWI Slave (EEprom)

Die Biblitothek ermöglicht eine I2C/TWI Kommunikation über das USI Interface von Atmel. Der verwendete Controller wird dabei als Slave in dem Bussystem verwendet. Neben Controllern der Reihe ATTiny, wie dem ATTiny2313, werden auch eine Reihe von anderen Controllern mit USI Interface unterstützt. Die Bibliothek ist so programmiert, dass der Slave wie ein I2C-Speicher (I2C-Epprom) funktioniert.

unterstützt werden bisher folgende Controller: ATtiny2313, ATtiny25, ATtiny45, ATtiny85, ATtiny26, ATtiny261, ATtiny461, ATtiny861, ATmega165, ATmega325, ATmega3250, ATmega645, ATmega6450, ATmega329, ATmega3290, ATmega169

Description The Slave works like a I2C-EEPROM.

  1. send - "Slave-Address + write"
  2. send - "Buffer-Address" Address in which you like to start with write or read. 
  write data in to Slave rxbuffer
  3.send - "SLave-Address + write"  
  4 send - "data" writes data in the buffer, start by rxbuffer[Buffer-Address] 
  or
  read data from Slave txbuffer
  3 send - "SLave-Address + read"     
  4 send - "data = i2c_readAck()" Demands the Slave to send data, start by txbuffer[Buffer-Address].

Info:

  • you have to change the buffer_size in the usiTwiSlave.h file
  • Buffer-Address is counted up automatically
  • if (Buffer-Address > buffersize) --> start by Buffer-Address= 0



USI Interface Register

hier als I2C/TWI:

// 2-wire mode; Hold SCL on start and overflow; ext. clock
USICR |= (1<<USIWM1) | (1<<USIWM0) | (1<<USICS1);

Mit dieser Konfiguration gelten folgende Tabellen für SDA respektive SCL Pin:

SDA
DDR SDA Shiftreg. Bit 7 PORT SDA PIN SDA
0 X X 1
1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 1


SCL
DDR SCL Startdet. Overflowdet. PORT SCL PIN SCL
0 X X X 1
1 0 0 0 0
1 0 0 1 1
1 0 1 0 0
1 0 1 1 0
1 1 0 0 0
1 1 0 1 0
1 1 1 0 0
1 1 1 1 0

Forum


Weblinks