Docsity

spi table for structure, Cheat Sheet of Microprocessors

Partial preview of the text

Download spi table for structure and more Cheat Sheet Microprocessors in PDF only on Docsity!

SPI Pin SPSRO ~ PADLADCOREINTH) SPI Status Register 0 PA1(ADCI/PCINT!) PA2(ADC2/PCINT2} - W/O address: $2D (PCINT8/XCKO/TO) PBO ff 4 (PCINT9/CLKOIT1) PB1 | 2 (PCINTIOANTZAINO) Pa2 FE 2 (PCINTIL/OCOA/AINI) PBS [al 4 PA3(ADC3PCINTS) - SRAM address: $4D (PCINT12/OCOB/ $S)PB4 [| 5 PA4(ADC4/PCINT4) Bit T 6 5 4 3 2 1 0 (PCINTL3/MOSI) PBS 6 PAS (ADCS/PCINTS} [sro | weow | ‘SPIZXO (PCINT14/MISO) PB6- 7 PA6(ADC6/PCINT6) Access R R RW (PCINT15/SCK) PB7 | 8 PAT(ADC7/PCINT7) RESET g AREF SPI vee EL “0 ono SPIFO (SPI Interrupt Flag) cno m1 avec SPIFO = 1: Aserial transfer is completed i % BE (IOSSUPCINIZS) The SS pin is driven low in slave mode 13 PCS (TOSCI/PCINT22) -n. + . ccummiespn PSO aE sos ABRIET SPIFO = 0: By first reading the SPSRO with SPIF set, (PCINT2S/TXDO) PO fH 15 PC4 (TDOPCINT20) then accessing the SPDRO (PCINT26/RXDI/INTO) PD? 2 16 PC3 (TMS/PCINTI9) Baw WCOLO (Write Collision) (PCINT27/TXD1/INT1) POS 17 PC2 (TCK/PCINTI8) Boe (PCINT28/XCKI/OC1B) PD4 | 8 PC1 (SDA/PCINTI7) = ae SPI2X0 (Double SPI Speed) (PCINT29/OC1A) PDS [i 19 PCO (SCLIPCINTL6) o~ (PCINT3O/OC7A/ICPI) POG | 20 PDT (OC2A/PCINTS!) Bowe Nguyén Trung Hiéu 60 l SPDRO Send and Read Data using SPI SPI Data Register 0 - (/O address: $2E - SRAM address: $4E SPI_Transmit: ot 7 6 5 4 3 2 1 0 OUT SPDRO,R16 - - ene) Z Wait_Transmit: Access RW Raw RaW mw RAV Rw Raw RAV IN R18, SPSRO SBRS R18, SPIFO | Wait for transmission done RJMP WAIT_TRANSMIT (IN. R17,SPDRO0) Read data from SPI RET (Optional) Send data through SPI The SPDRO is a read/write register used for data transfer between the Register File and the SPI Shift Register. ¢ Writing to the SPDRO initiates data transmission. « Reading the SPDRO causes the Shift Register Receive buffer to be read. Nguyn Trung Hiéu 62 SPCRO SPI Control Register 0 Bi it 5 SPCRO os i; 0 SPIEO DORDO | MSTRO crow | crrad | SPROV_| SPROO . VO address: $2C Access RW RW RW RW RW RW RW RW - SRAM address: $4C “aS a ‘ i ¥ 6 i a * a 6 5 4 3 2 1 ° [sr iro WCOLO I | ([__sPizxo SPIED ‘SPEO DORDO TaSTRO CPOE GPHAO SPROT SPROO Access R R RAV 36 RWW RAW RW SPI2X SPRO1 SPROO SCK Frequency 0 ty) 0 fosel4 MSTRO (Master/Slave Select): 0 0 4 fosel16 * 1: Master + 0:Slave 0 1 0 fosol64 0 1 4 fose!128 DORDO (Data0 Order): 1 0 0 fosc!2 + 1: LSB first + 0: MSB first 1 0 1 fose!® SPEO (SPI enable): 1 1 0 fosel32 * 1: SPI enable 1 ‘| id foscl64 + 0: SPI disable ° Example: Initialize the SPI Explain mode of SPI in this subroutine? -EQU SPI_PORT=PORTB -EQU SPI_LPORT_DDR=DDRB -EQU SS=4 -EQU MOSI=5 -EQU MISO=6 -EQU SCK=7 SPI_INIT: LDI R16,(41<