spi_casestudy

13
Case Study Serial Peripheral Interface on ARM Microcontrollers

Upload: ashish-rawat

Post on 22-Apr-2015

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SPI_casestudy

Case Study Serial Peripheral Interface on ARM

Microcontrollers

Page 2: SPI_casestudy

Contents

1. RFID reader design2. Why SPI? Why not I2C?3. SPI in Linux OS4. Understanding device5. Parameters6. Implementation7. Conclusion

Page 3: SPI_casestudy

RFID reader design

Master – mini2440 (S3C2440 ARM9 Microcontroller)

Slave – AS3991 UHF RFID reader IC

Page 4: SPI_casestudy

mini2440

AS3991

CLKSSMISOMOSI

GND EN

Vext

Irq

Page 5: SPI_casestudy

Why SPI? Why not I2C?

AS3991 provides a SPI or parallel communication with microcontroller

•Higher data transfer rate•Single slave•Full duplex

Page 6: SPI_casestudy

SPI in Linux OS

•No need to learn configuration registers or buffer register(Hardware Independent)

•Kernel will give you access to SPI device as spidev0.0 or spidev1.1

•No change in programs for different hardware

Page 7: SPI_casestudy

Understanding device

• What are transfer rate device support• CPOL and CPHA• CS select• Signal level for communication • Commands – most important and varies with device

Page 8: SPI_casestudy
Page 9: SPI_casestudy

Parameters

•Device(spidev0.0)•Clock speed•modes

• CPOL• CPHA

•3-wire mode•Chip Select(Active high or low)

Page 10: SPI_casestudy

A Code Walkthroughstart

Include headersDefine variables

Void main(--)

transferCall transfer

Is transferComplete?

END

Display response

Page 11: SPI_casestudy

Implementation

[root@FriendlyARM /udisk]# ./readallreg -H spi mode: 1 bits per word: 8 max speed: 500000 Hz (500 KHz)  00 03 03 02 02 F0 F0 62 62 35 35 05 05 00 00 07 07 07 07 41 41 01 01 02 02 81 00 37 37 07 07 00 00 00 00 00 00 38 38 00 00 00 00 00 00 00 00 00 00 00 00

Transmit buffer contains - tx_buf[]= {0x40,0x40,0x41,0x41,0x42,0x42,0x43,0x43,0x44,0x44,0x45,0x45,0x46,0x46,0x47,0x47,0x48,0x48,0x49,0x49,0x4A,0x4A,0x4B,0x4B,0x4C,0x4C,0x4D,0x4D,0x4E,0x4E,0x4F,0x4F,0x50,0x50,0x51,0x51,0x52,0x53,0x53

}

Page 12: SPI_casestudy

Conclusion

• RF device is studied in detail• operating parameters are decided• SPI communication is established and verified

Page 13: SPI_casestudy

Thank You!