USI

Aus der Mikrocontroller.net Artikelsammlung, mit Beiträgen verschiedener Autoren (siehe Versionsgeschichte)
Wechseln zu: Navigation, Suche

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