spi_casestudy
TRANSCRIPT
Case Study Serial Peripheral Interface on ARM
Microcontrollers
Contents
1. RFID reader design2. Why SPI? Why not I2C?3. SPI in Linux OS4. Understanding device5. Parameters6. Implementation7. Conclusion
RFID reader design
Master – mini2440 (S3C2440 ARM9 Microcontroller)
Slave – AS3991 UHF RFID reader IC
mini2440
AS3991
CLKSSMISOMOSI
GND EN
Vext
Irq
Why SPI? Why not I2C?
AS3991 provides a SPI or parallel communication with microcontroller
•Higher data transfer rate•Single slave•Full duplex
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
Understanding device
• What are transfer rate device support• CPOL and CPHA• CS select• Signal level for communication • Commands – most important and varies with device
Parameters
•Device(spidev0.0)•Clock speed•modes
• CPOL• CPHA
•3-wire mode•Chip Select(Active high or low)
A Code Walkthroughstart
Include headersDefine variables
Void main(--)
transferCall transfer
Is transferComplete?
END
Display response
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
}
Conclusion
• RF device is studied in detail• operating parameters are decided• SPI communication is established and verified
Thank You!