SlideShare a Scribd company logo
SPI INTERFACE
Joseph
2016/08/08
1
SPI 線路
2
SPI 為一個Ring 結構:要讀資料,必送資料
{dummy byte}
CPOL: rest state of clock (high or low)
CPHA: First or second SCLK transition
CPOL,CPHA 用來決定latch 資料的時間點
SPI 模式
3
Serial Flash (SPI interface)
Flash size: 4Mbit
1) 64K Block size (Block Erase)
2) 4K Sector size (Sector Erase, Block_Erase_4K)
3) 256 Byte Page size (Page Program)
Single Power Supply Operation
• 2.7 to 3.6 volt for read, erase, and program operations
SPI Modes : Mode 0 & Mode 1
注意:
1) Flash 要寫入page之前,要先Erase
2) Page Program->"0", Erase -->"1"
3) 傳送順序為 MSB First
MX25L4005A 規格
4
MX25L4005A Addressing (3 byte)
Flash Memory Organization
Page #Sector #Block #
11 01523 18 12 8 7
Offset #
AD1 AD2 AD3
16
Sector Address A[18:12]
MSB LSB
Page Program (0x02)Page Address A[18:8] + Offset A[7:0]
. . .
256 byte
1 page=256 bytes
Sector Erase (0x20)
5
16 pages
Read Status Register (RDSR)
6
Command Table
7
對於 PP, SE, BE, CE, and WRSR 會改變Flash內容的Command, 都
要先設定WEL bit=1 (in RDSR bit 1), 一旦操作完成後, 它會自動reset
(將WEL bit設回0)
操作方法:
MX25L4005A 操作方法
CS# goes low
sending WREN (0x6); // set WEL=1
CS# goes high
CS# goes low
sending <CMD>+{Flash Address}+{Data}; //see command table
CS# goes high
CS# goes low
deadline = jiffies + MAX_READY_WAIT_JIFFIES;
do {
status=sending RDSR(0x5) ;
if (!(status & WIP) ) return 0; //判斷是否操作完成
cond_resched(); // 再排程
} while (!time_after_eq(jiffies, deadline));
CS# goes high
8
Read ID command
MX25L4005A FlashID:C22013
C2 20 13
9
Page Program
送出24 bit Address 決定了寫入位址(page+offset)後, 接著就是在這個page內偱序寫入資料。
因為page size為256 byte, 所以最多只能寫256 Byte, 超過會覆蓋到同page的開頭
10
write_flash(addr, buf, len) ;
在位址 0x2085, 寫入長度是786 byte時, 該進行何種程序? 假設
Page 為256 bytes
Answer:要執行4次Page Program cycle (每次不同的Page address)
Quiz
11
addr
len
page
PP(0x2100,256)
PP(0x2200,256)
PP(0x2300,151)
PP(0x2085,123)
page offset 0x85
SPI 操作-big-banging
void SendByte( uint8 byte_value )
{
uint16 i;
uint8 cycle_cnt;
cycle_cnt = 8;
for( i= 0; i < cycle_cnt; i++ )
{
if ( (byte_value & IO_MASK) == 0x80 ){
SI = 1;
}
else{
SI = 0;
}
SCLK = 0;
byte_value = byte_value << 1;
SCLK = 1;
}
}
uint8 GetByte( )
{
uint16 i;
uint8 cycle_cnt;
uint8 data_buf;
data_buf = 0;
cycle_cnt = 8;
for( i= 0; i < cycle_cnt; i++ )
{
SCLK = 0;
if ( SO == 1 ){
data_buf = (data_buf | (0x80 >> i));
}
SCLK = 1;
}
return data_buf;
}
SCLK = 1; // init Flash input clock
12
SPI Mode : 3
SPI 操作 - big-banging
ReturnMsg CMD_RDID( uint32 *Identification )
{
uint32 temp;
uint8 gDataBuffer[3];
// Chip select go low to start a flash command
CS_Low();
// Send command
#define FLASH_CMD_RDID 0x9F //RDID (Read Identification)
SendByte( FLASH_CMD_RDID);
// Get manufacturer identification, device identification
gDataBuffer[0] = GetByte( );
gDataBuffer[1] = GetByte( );
gDataBuffer[2] = GetByte( );
// Chip select go high to end a command
CS_High();
// Store identification
temp = gDataBuffer[0];
temp = (temp << 8) | gDataBuffer[1];
*Identification = (temp << 8) | gDataBuffer[2];
// Flash ID:C22013
return FlashOperationSuccess;
}
13
ADC (MCP3008)
2.7V 4-Channel/8-Channel 10-Bit A/D Converters with SPI Serial Interface
4 pseudo-differential input pairs or 8 single-ended inputs
LSB: 最小刻度
VREF determines the
analog input voltage range
SPI COMMUNICATION
SPI Interface

More Related Content

What's hot

Serial peripheral interface
Serial peripheral interfaceSerial peripheral interface
Serial peripheral interface
Abhijeet kapse
 
Linkmeup v23-compass-eos
Linkmeup v23-compass-eosLinkmeup v23-compass-eos
Linkmeup v23-compass-eos
eucariot
 
I2C
I2CI2C
Llpc2148 sci
Llpc2148 sciLlpc2148 sci
Llpc2148 scianishgoel
 
COMPLETE DETAIL OF ARM PART 3
COMPLETE DETAIL OF ARM PART 3COMPLETE DETAIL OF ARM PART 3
COMPLETE DETAIL OF ARM PART 3
NOWAY
 
OSPF Internal Route Summarization
OSPF Internal Route SummarizationOSPF Internal Route Summarization
OSPF Internal Route Summarization
NetProtocol Xpert
 
Redistribution into OSPF
Redistribution into OSPFRedistribution into OSPF
Redistribution into OSPF
NetProtocol Xpert
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
Anurag Tomar
 
Serial connectors, Protocols , USB (universal serial bus)
Serial connectors, Protocols , USB (universal serial bus)Serial connectors, Protocols , USB (universal serial bus)
Serial connectors, Protocols , USB (universal serial bus)
A. Shamel
 
I2 c communication protocol
I2 c communication protocolI2 c communication protocol
I2 c communication protocol
ShankaranarayanaBarr
 
arm complete detail part 2
arm complete detail part 2arm complete detail part 2
arm complete detail part 2
NOWAY
 
CCNA ppt Day 7
CCNA ppt Day 7CCNA ppt Day 7
CCNA ppt Day 7
VISHNU N
 
Лекц 8
Лекц 8Лекц 8
Лекц 8Muuluu
 
FAR/MARS Avionics CDR
FAR/MARS Avionics CDRFAR/MARS Avionics CDR
FAR/MARS Avionics CDR
Cade Walton
 
Switch configuration
Switch configurationSwitch configuration
Switch configurationMuuluu
 
I2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication ProtocolI2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication Protocol
Ankur Soni
 
My i2c
My i2cMy i2c
SPI Bus Protocol
SPI Bus ProtocolSPI Bus Protocol
SPI Bus Protocol
Sudhanshu Janwadkar
 
I2c buses
I2c busesI2c buses
I2c buses
Naveen Dubey
 

What's hot (20)

Serial peripheral interface
Serial peripheral interfaceSerial peripheral interface
Serial peripheral interface
 
Linkmeup v23-compass-eos
Linkmeup v23-compass-eosLinkmeup v23-compass-eos
Linkmeup v23-compass-eos
 
I2C
I2CI2C
I2C
 
Llpc2148 sci
Llpc2148 sciLlpc2148 sci
Llpc2148 sci
 
COMPLETE DETAIL OF ARM PART 3
COMPLETE DETAIL OF ARM PART 3COMPLETE DETAIL OF ARM PART 3
COMPLETE DETAIL OF ARM PART 3
 
OSPF Internal Route Summarization
OSPF Internal Route SummarizationOSPF Internal Route Summarization
OSPF Internal Route Summarization
 
Spi (1)
Spi (1)Spi (1)
Spi (1)
 
Redistribution into OSPF
Redistribution into OSPFRedistribution into OSPF
Redistribution into OSPF
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
 
Serial connectors, Protocols , USB (universal serial bus)
Serial connectors, Protocols , USB (universal serial bus)Serial connectors, Protocols , USB (universal serial bus)
Serial connectors, Protocols , USB (universal serial bus)
 
I2 c communication protocol
I2 c communication protocolI2 c communication protocol
I2 c communication protocol
 
arm complete detail part 2
arm complete detail part 2arm complete detail part 2
arm complete detail part 2
 
CCNA ppt Day 7
CCNA ppt Day 7CCNA ppt Day 7
CCNA ppt Day 7
 
Лекц 8
Лекц 8Лекц 8
Лекц 8
 
FAR/MARS Avionics CDR
FAR/MARS Avionics CDRFAR/MARS Avionics CDR
FAR/MARS Avionics CDR
 
Switch configuration
Switch configurationSwitch configuration
Switch configuration
 
I2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication ProtocolI2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication Protocol
 
My i2c
My i2cMy i2c
My i2c
 
SPI Bus Protocol
SPI Bus ProtocolSPI Bus Protocol
SPI Bus Protocol
 
I2c buses
I2c busesI2c buses
I2c buses
 

Similar to SPI Interface

[KOR] ODI no.004 analysis of oracle performance degradation caused by ineffic...
[KOR] ODI no.004 analysis of oracle performance degradation caused by ineffic...[KOR] ODI no.004 analysis of oracle performance degradation caused by ineffic...
[KOR] ODI no.004 analysis of oracle performance degradation caused by ineffic...
EXEM
 
POWER10 innovations for HPC
POWER10 innovations for HPCPOWER10 innovations for HPC
POWER10 innovations for HPC
Ganesan Narayanasamy
 
The Quantum Physics of Java
The Quantum Physics of JavaThe Quantum Physics of Java
The Quantum Physics of Java
Michael Heinrichs
 
DOAG Security Day 2016 Enterprise Security Reloaded
DOAG Security Day 2016 Enterprise Security ReloadedDOAG Security Day 2016 Enterprise Security Reloaded
DOAG Security Day 2016 Enterprise Security Reloaded
Loopback.ORG
 
Super scaling singleton inserts
Super scaling singleton insertsSuper scaling singleton inserts
Super scaling singleton inserts
Chris Adkin
 
Cisco EuroMPI'13 vendor session presentation
Cisco EuroMPI'13 vendor session presentationCisco EuroMPI'13 vendor session presentation
Cisco EuroMPI'13 vendor session presentationJeff Squyres
 
8051 skb's- part - i
8051  skb's- part - i8051  skb's- part - i
助教が吼える! 各界の若手研究者大集合「ハードウェアはやわらかい」
助教が吼える! 各界の若手研究者大集合「ハードウェアはやわらかい」助教が吼える! 各界の若手研究者大集合「ハードウェアはやわらかい」
助教が吼える! 各界の若手研究者大集合「ハードウェアはやわらかい」
Shinya Takamaeda-Y
 
了解Cpu
了解Cpu了解Cpu
了解Cpu
Feng Yu
 
Design and Implementation of 64 Bit RISC Processor Using System.pdf
Design and Implementation of 64 Bit RISC Processor Using System.pdfDesign and Implementation of 64 Bit RISC Processor Using System.pdf
Design and Implementation of 64 Bit RISC Processor Using System.pdf
ChowdappaKv1
 
Oracle Deep Internal 4 (ver.2)
Oracle Deep Internal 4 (ver.2)Oracle Deep Internal 4 (ver.2)
Oracle Deep Internal 4 (ver.2)
EXEM
 
Proving out flash storage array performance using swingbench and slob
Proving out flash storage array performance using swingbench and slobProving out flash storage array performance using swingbench and slob
Proving out flash storage array performance using swingbench and slob
Kapil Goyal
 
Microprocessor Week1: Introduction
Microprocessor Week1: IntroductionMicroprocessor Week1: Introduction
Microprocessor Week1: Introduction
Arkhom Jodtang
 
lecture16-recap-questions-and-answers.pdf
lecture16-recap-questions-and-answers.pdflecture16-recap-questions-and-answers.pdf
lecture16-recap-questions-and-answers.pdf
AyushKumar93531
 
QSpiders - Basic intel architecture
QSpiders - Basic intel architectureQSpiders - Basic intel architecture
QSpiders - Basic intel architecture
Qspiders - Software Testing Training Institute
 
了解网络
了解网络了解网络
了解网络
Feng Yu
 
Exploiting GPU's for Columnar DataFrrames by Kiran Lonikar
Exploiting GPU's for Columnar DataFrrames by Kiran LonikarExploiting GPU's for Columnar DataFrrames by Kiran Lonikar
Exploiting GPU's for Columnar DataFrrames by Kiran Lonikar
Spark Summit
 

Similar to SPI Interface (20)

[KOR] ODI no.004 analysis of oracle performance degradation caused by ineffic...
[KOR] ODI no.004 analysis of oracle performance degradation caused by ineffic...[KOR] ODI no.004 analysis of oracle performance degradation caused by ineffic...
[KOR] ODI no.004 analysis of oracle performance degradation caused by ineffic...
 
POWER10 innovations for HPC
POWER10 innovations for HPCPOWER10 innovations for HPC
POWER10 innovations for HPC
 
The Quantum Physics of Java
The Quantum Physics of JavaThe Quantum Physics of Java
The Quantum Physics of Java
 
DOAG Security Day 2016 Enterprise Security Reloaded
DOAG Security Day 2016 Enterprise Security ReloadedDOAG Security Day 2016 Enterprise Security Reloaded
DOAG Security Day 2016 Enterprise Security Reloaded
 
Super scaling singleton inserts
Super scaling singleton insertsSuper scaling singleton inserts
Super scaling singleton inserts
 
Cisco EuroMPI'13 vendor session presentation
Cisco EuroMPI'13 vendor session presentationCisco EuroMPI'13 vendor session presentation
Cisco EuroMPI'13 vendor session presentation
 
MaPU-HPCA2016
MaPU-HPCA2016MaPU-HPCA2016
MaPU-HPCA2016
 
8051 skb's- part - i
8051  skb's- part - i8051  skb's- part - i
8051 skb's- part - i
 
助教が吼える! 各界の若手研究者大集合「ハードウェアはやわらかい」
助教が吼える! 各界の若手研究者大集合「ハードウェアはやわらかい」助教が吼える! 各界の若手研究者大集合「ハードウェアはやわらかい」
助教が吼える! 各界の若手研究者大集合「ハードウェアはやわらかい」
 
了解Cpu
了解Cpu了解Cpu
了解Cpu
 
Design and Implementation of 64 Bit RISC Processor Using System.pdf
Design and Implementation of 64 Bit RISC Processor Using System.pdfDesign and Implementation of 64 Bit RISC Processor Using System.pdf
Design and Implementation of 64 Bit RISC Processor Using System.pdf
 
Oracle Deep Internal 4 (ver.2)
Oracle Deep Internal 4 (ver.2)Oracle Deep Internal 4 (ver.2)
Oracle Deep Internal 4 (ver.2)
 
Proving out flash storage array performance using swingbench and slob
Proving out flash storage array performance using swingbench and slobProving out flash storage array performance using swingbench and slob
Proving out flash storage array performance using swingbench and slob
 
Microprocessor Week1: Introduction
Microprocessor Week1: IntroductionMicroprocessor Week1: Introduction
Microprocessor Week1: Introduction
 
lecture16-recap-questions-and-answers.pdf
lecture16-recap-questions-and-answers.pdflecture16-recap-questions-and-answers.pdf
lecture16-recap-questions-and-answers.pdf
 
IPv6 Static Routes
IPv6 Static RoutesIPv6 Static Routes
IPv6 Static Routes
 
8051
80518051
8051
 
QSpiders - Basic intel architecture
QSpiders - Basic intel architectureQSpiders - Basic intel architecture
QSpiders - Basic intel architecture
 
了解网络
了解网络了解网络
了解网络
 
Exploiting GPU's for Columnar DataFrrames by Kiran Lonikar
Exploiting GPU's for Columnar DataFrrames by Kiran LonikarExploiting GPU's for Columnar DataFrrames by Kiran Lonikar
Exploiting GPU's for Columnar DataFrrames by Kiran Lonikar
 

More from 艾鍗科技

TinyML - 4 speech recognition
TinyML - 4 speech recognition TinyML - 4 speech recognition
TinyML - 4 speech recognition
艾鍗科技
 
Appendix 1 Goolge colab
Appendix 1 Goolge colabAppendix 1 Goolge colab
Appendix 1 Goolge colab
艾鍗科技
 
Project-IOT於餐館系統的應用
Project-IOT於餐館系統的應用Project-IOT於餐館系統的應用
Project-IOT於餐館系統的應用
艾鍗科技
 
02 IoT implementation
02 IoT implementation02 IoT implementation
02 IoT implementation
艾鍗科技
 
Tiny ML for spark Fun Edge
Tiny ML for spark Fun EdgeTiny ML for spark Fun Edge
Tiny ML for spark Fun Edge
艾鍗科技
 
Openvino ncs2
Openvino ncs2Openvino ncs2
Openvino ncs2
艾鍗科技
 
Step motor
Step motorStep motor
Step motor
艾鍗科技
 
2. 機器學習簡介
2. 機器學習簡介2. 機器學習簡介
2. 機器學習簡介
艾鍗科技
 
5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron) 5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron)
艾鍗科技
 
3. data features
3. data features3. data features
3. data features
艾鍗科技
 
心率血氧檢測與運動促進
心率血氧檢測與運動促進心率血氧檢測與運動促進
心率血氧檢測與運動促進
艾鍗科技
 
利用音樂&情境燈幫助放鬆
利用音樂&情境燈幫助放鬆利用音樂&情境燈幫助放鬆
利用音樂&情境燈幫助放鬆
艾鍗科技
 
IoT感測器驅動程式 在樹莓派上實作
IoT感測器驅動程式在樹莓派上實作IoT感測器驅動程式在樹莓派上實作
IoT感測器驅動程式 在樹莓派上實作
艾鍗科技
 
無線聲控遙控車
無線聲控遙控車無線聲控遙控車
無線聲控遙控車
艾鍗科技
 
最佳光源的研究和實作
最佳光源的研究和實作最佳光源的研究和實作
最佳光源的研究和實作
艾鍗科技
 
無線監控網路攝影機與控制自走車
無線監控網路攝影機與控制自走車無線監控網路攝影機與控制自走車
無線監控網路攝影機與控制自走車
艾鍗科技
 
Reinforcement Learning
Reinforcement LearningReinforcement Learning
Reinforcement Learning
艾鍗科技
 
Linux Device Tree
Linux Device TreeLinux Device Tree
Linux Device Tree
艾鍗科技
 
人臉辨識考勤系統
人臉辨識考勤系統人臉辨識考勤系統
人臉辨識考勤系統
艾鍗科技
 
智慧家庭Smart Home
智慧家庭Smart Home智慧家庭Smart Home
智慧家庭Smart Home
艾鍗科技
 

More from 艾鍗科技 (20)

TinyML - 4 speech recognition
TinyML - 4 speech recognition TinyML - 4 speech recognition
TinyML - 4 speech recognition
 
Appendix 1 Goolge colab
Appendix 1 Goolge colabAppendix 1 Goolge colab
Appendix 1 Goolge colab
 
Project-IOT於餐館系統的應用
Project-IOT於餐館系統的應用Project-IOT於餐館系統的應用
Project-IOT於餐館系統的應用
 
02 IoT implementation
02 IoT implementation02 IoT implementation
02 IoT implementation
 
Tiny ML for spark Fun Edge
Tiny ML for spark Fun EdgeTiny ML for spark Fun Edge
Tiny ML for spark Fun Edge
 
Openvino ncs2
Openvino ncs2Openvino ncs2
Openvino ncs2
 
Step motor
Step motorStep motor
Step motor
 
2. 機器學習簡介
2. 機器學習簡介2. 機器學習簡介
2. 機器學習簡介
 
5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron) 5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron)
 
3. data features
3. data features3. data features
3. data features
 
心率血氧檢測與運動促進
心率血氧檢測與運動促進心率血氧檢測與運動促進
心率血氧檢測與運動促進
 
利用音樂&情境燈幫助放鬆
利用音樂&情境燈幫助放鬆利用音樂&情境燈幫助放鬆
利用音樂&情境燈幫助放鬆
 
IoT感測器驅動程式 在樹莓派上實作
IoT感測器驅動程式在樹莓派上實作IoT感測器驅動程式在樹莓派上實作
IoT感測器驅動程式 在樹莓派上實作
 
無線聲控遙控車
無線聲控遙控車無線聲控遙控車
無線聲控遙控車
 
最佳光源的研究和實作
最佳光源的研究和實作最佳光源的研究和實作
最佳光源的研究和實作
 
無線監控網路攝影機與控制自走車
無線監控網路攝影機與控制自走車無線監控網路攝影機與控制自走車
無線監控網路攝影機與控制自走車
 
Reinforcement Learning
Reinforcement LearningReinforcement Learning
Reinforcement Learning
 
Linux Device Tree
Linux Device TreeLinux Device Tree
Linux Device Tree
 
人臉辨識考勤系統
人臉辨識考勤系統人臉辨識考勤系統
人臉辨識考勤系統
 
智慧家庭Smart Home
智慧家庭Smart Home智慧家庭Smart Home
智慧家庭Smart Home
 

Recently uploaded

space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
top1002
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
veerababupersonal22
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
symbo111
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 

Recently uploaded (20)

space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 

SPI Interface

  • 2. SPI 線路 2 SPI 為一個Ring 結構:要讀資料,必送資料 {dummy byte}
  • 3. CPOL: rest state of clock (high or low) CPHA: First or second SCLK transition CPOL,CPHA 用來決定latch 資料的時間點 SPI 模式 3
  • 4. Serial Flash (SPI interface) Flash size: 4Mbit 1) 64K Block size (Block Erase) 2) 4K Sector size (Sector Erase, Block_Erase_4K) 3) 256 Byte Page size (Page Program) Single Power Supply Operation • 2.7 to 3.6 volt for read, erase, and program operations SPI Modes : Mode 0 & Mode 1 注意: 1) Flash 要寫入page之前,要先Erase 2) Page Program->"0", Erase -->"1" 3) 傳送順序為 MSB First MX25L4005A 規格 4
  • 5. MX25L4005A Addressing (3 byte) Flash Memory Organization Page #Sector #Block # 11 01523 18 12 8 7 Offset # AD1 AD2 AD3 16 Sector Address A[18:12] MSB LSB Page Program (0x02)Page Address A[18:8] + Offset A[7:0] . . . 256 byte 1 page=256 bytes Sector Erase (0x20) 5 16 pages
  • 8. 對於 PP, SE, BE, CE, and WRSR 會改變Flash內容的Command, 都 要先設定WEL bit=1 (in RDSR bit 1), 一旦操作完成後, 它會自動reset (將WEL bit設回0) 操作方法: MX25L4005A 操作方法 CS# goes low sending WREN (0x6); // set WEL=1 CS# goes high CS# goes low sending <CMD>+{Flash Address}+{Data}; //see command table CS# goes high CS# goes low deadline = jiffies + MAX_READY_WAIT_JIFFIES; do { status=sending RDSR(0x5) ; if (!(status & WIP) ) return 0; //判斷是否操作完成 cond_resched(); // 再排程 } while (!time_after_eq(jiffies, deadline)); CS# goes high 8
  • 9. Read ID command MX25L4005A FlashID:C22013 C2 20 13 9
  • 10. Page Program 送出24 bit Address 決定了寫入位址(page+offset)後, 接著就是在這個page內偱序寫入資料。 因為page size為256 byte, 所以最多只能寫256 Byte, 超過會覆蓋到同page的開頭 10
  • 11. write_flash(addr, buf, len) ; 在位址 0x2085, 寫入長度是786 byte時, 該進行何種程序? 假設 Page 為256 bytes Answer:要執行4次Page Program cycle (每次不同的Page address) Quiz 11 addr len page PP(0x2100,256) PP(0x2200,256) PP(0x2300,151) PP(0x2085,123) page offset 0x85
  • 12. SPI 操作-big-banging void SendByte( uint8 byte_value ) { uint16 i; uint8 cycle_cnt; cycle_cnt = 8; for( i= 0; i < cycle_cnt; i++ ) { if ( (byte_value & IO_MASK) == 0x80 ){ SI = 1; } else{ SI = 0; } SCLK = 0; byte_value = byte_value << 1; SCLK = 1; } } uint8 GetByte( ) { uint16 i; uint8 cycle_cnt; uint8 data_buf; data_buf = 0; cycle_cnt = 8; for( i= 0; i < cycle_cnt; i++ ) { SCLK = 0; if ( SO == 1 ){ data_buf = (data_buf | (0x80 >> i)); } SCLK = 1; } return data_buf; } SCLK = 1; // init Flash input clock 12 SPI Mode : 3
  • 13. SPI 操作 - big-banging ReturnMsg CMD_RDID( uint32 *Identification ) { uint32 temp; uint8 gDataBuffer[3]; // Chip select go low to start a flash command CS_Low(); // Send command #define FLASH_CMD_RDID 0x9F //RDID (Read Identification) SendByte( FLASH_CMD_RDID); // Get manufacturer identification, device identification gDataBuffer[0] = GetByte( ); gDataBuffer[1] = GetByte( ); gDataBuffer[2] = GetByte( ); // Chip select go high to end a command CS_High(); // Store identification temp = gDataBuffer[0]; temp = (temp << 8) | gDataBuffer[1]; *Identification = (temp << 8) | gDataBuffer[2]; // Flash ID:C22013 return FlashOperationSuccess; } 13
  • 14. ADC (MCP3008) 2.7V 4-Channel/8-Channel 10-Bit A/D Converters with SPI Serial Interface 4 pseudo-differential input pairs or 8 single-ended inputs
  • 15.
  • 16. LSB: 最小刻度 VREF determines the analog input voltage range