Interfejsy szeregowe Dariusz Chaberski
Interfejs I 2 C mikrokontroler A sterownik wyświetlacza LCD pamięć RAM lub EEPROM SDA SCL programowalna matryca bramek przetwornik A/C mikrokontroler B I 2 C - Inter IC - Inter Integrated Circuit 2
elektryczne podłączenie dwóch urządzeń z wykorzystaniem magistrali I 2 C SDA(Serial Data Line)- linia danych SCL(Serial Clock Line)- linia zegara V DD rezystory podwieszające Rp R p CLK1 OUT DATA1 OUT CLK2 OUT DATA2 OUT CLK1 IN DATA1 IN CLK2 IN DATA2 IN urządzenie 1 urządzenie 2 3
transfer pojedynczego bitu SDA SCL linia danych stabilna zmiana danych dozwolona 4
rozpoczęcie i zakończenie transmisji SDA SCL S warunek STARTu P warunek STOPu 5
transfer danych (2 bajty) P SDA MSB potwierdzenie z układu podrzędnego bajt skompletowany- przerwanie wewnątrz układu podrzędnego linia zegara utrzymywana na niskim poziomie w momencie obsługi przerwania Sr SCL S lub Sr 1 2 7 8 9 ACK 1 2 3-8 9 ACK Sr lub P warunek Startu lub powtórzonego Startu warunek Stopu lub powtórzonego Startu 6
potwierdzenie SDA(nadajnik) brak potwierdzenia SDA(odbiornik) potwierdzenie SCL(układ nadrzędny) S 1 2 8 9 warunek Startu impuls zegarowy dla potwierdzenia 7
synchronizacja zegara podczas procedury arbitrażu stan oczekiwania rozpoczęcie odmierzania czasu trwania stanu wysokiego SCL(1) reset licznika SCL(2) SCL 8
procedura arbitrażu dwóch MASTERów układ nadrzędny 1 traci arbitraż SDA1 SDA SDA(1) SDA(2) SDA SCL S 9
kompletny transfer danych SDA SCL S 1-7 8 9 1-7 8 9 1-7 8 9 P warunek Startu adres R/W potwierdzenie dane potwierdzenie dane potwierdzenie warunek Stopu 10
adresowanie SLAVE a 7-bitowym adresem poprzez MASTERa, który jest nadajnikiem natychmiastowy odczyt SLAVE a 11
format kombinowany 12
PCF8574 Remote 8-bit I/O expander for I2C-bus 13
Simplified schematic diagram of each I/O 14
Addressing 15
WRITE mode (output) 16
READ mode (input) 17
Interrupt generated by a change of input to I/O P5 18
Transient pull-up current I OHt while P3 changes from LOW-to-HIGH and back to LOW 19
Interfejs SPI 20
SPI Transfer Format with CPHA = 0 (8-bit) 21
SPI Transfer Format with CPHA = 1 (8-bit) 22
16-bit SPI Transfer Format 23
Setup & Hold Timing 24
Timing Master Mode 25
Timing Slave Mode 26
USART Universal (Synchronous) Asynchronous Receiver Transmitter UART TX/RX Sta D0 D1 D2 D3 D4[D5][D6][D7] Pa Sto Sto RS - Recommended Standard RS 232 H = -12 V, L = +12V RXD Received exchange Data TXD Transmit exchange Data TX/RX Sta D0 D1 D2 27
USRT CLK TX/RX D0 D1 D2 D3 D4[D5][D6][D7] Pa TX/RX -> CLK 28
1-Wire 29
Pin electrical scheme 30
Communication sequence 31
WRITE/READ 32
1-Wire waveforms/master Timing 33
RESET unsigned char reset1w(void){ unsigned char ret=0, i; PORTA&=0xfe; DDRA =0x01; for(i=0; i<48; i++) delay us(10); DDRA&=0xfe; PORTA =0x01; delay us(65); if((pina&0x01)==0x00) ret=1; delay us(90); if((pina&0x01)==0x00) ret=0; for(i=0; i<15; i++) delay us(30); return ret; } 34
WRITE void w1w(unsigned char w){ unsigned char i; for(i=0; i<8; i++){ PORTA&=0xfe; DDRA =0x01; delay us(11); if((w & (1<<i))==0) delay us(60); DDRA&=0xfe; PORTA =0x01; delay us(60); } } 35
READ unsigned char r1w(void){ unsigned char i, ret=0, j; for(i=0; i<8; i++){ PORTA&=0xfe; DDRA =0x01; delay us(1); DDRA&=0xfe; PORTA =0x01; delay us(14); if((pina & 0x01)!=0) ret =(1<<i); delay us(60); } return ret; } 36
8-bit CRC (Cyclic Redundancy Check) 37
unsigned char crc1w(unsigned char * tab){ unsigned char crc=0, i, j, t1, t2, t, tt=0; for(i=0; i<8; i++){ t=tab[i]; t1=t; for(j=0; j<8; j++){ t^=crc; t2=t&0x01; t=crc; if(t2) t^=0x18; t=(t>>1)+0x80*t2; crc=t; t1=(t=t1>>1); } tt =tab[i]; } if(tt==0) return 1; return crc; } 38
JTAG Boundary-Scan Testing Using the IEEE Std 1149.1 Bus 39
Boundary-Scan Example 40
Boundary-Scan Architecture TAP - Test Access Port 41
TAP Controller State Diagram 42
TAP Control Output Interconnect Diagram 43
General Instruction Register Architecture 44
Test Data Register Architecture 45
Conceptual View of a Control-and-Observe BSC BSC - Boundary-Scan Cell 46
Backplane Ring Configuration 47
Backplane Star Configuration 48
USB Speed Low Speed 1.5 Mb/s (USB 1.0, USB 2.0) Full Speed - 12 Mb/s (USB 1.0, USB 2.0) High Speed - 480 Mb/s (USB 2.0) Transfer Types Control (identification and configuration) - Required Bulk (printer, scanner, drive) Interrupt (mouse, keyboard) Isochronous (streaming audio, video) 49
Bus Topology 50
USB Communication Flow 51
USB Cable 5 m max 52
Keyed Connector Protocol 53
Example High-speed Capable Transceiver Circuit 54
NRZI Data Encoding Data Encoding Sequence (Bit Stuffing) 55
Packet Identifier Field 56
PID Types 57
58
Address Field Endpoint Field Control pipe @ endpoint 0 Data Field (range from 0 to 1024 bytes - integral number of bytes) 59
Token CRCs G(X) = X 5 + X 2 + 1 bit pattern = 00101B the five-bit residual = 01100B Data CRCs G(X) = X 16 + X 15 + X 2 + 1 bit pattern = 1000000000000101B the 16-bit residual = 1000000000001101B 60
Token Packets 61
Packets in a Start-split Transaction Packets in a Complete-split Transaction 62
Relationship of Interrupt IN Transaction to High-speed Split Transaction 63
Relationship of Interrupt OUT Transaction to High-speed Split OUT Transaction 64
Start-Split Transaction Token 65
Complete-Split Transaction Token 66
Start-of-Frame Packets 67
USB Frames and Microframes 68
Data Packets Handshake Packets ACK, NAK, STALL, NYET, ERR 69
Bulk Transactions 70
Control Transfers (SETUP) 71
Interrupt Transactions 72
Isochronous Transactions 73