摘 要:提出一種基于FPGA實現SPI接口與RS 232接口轉換的方法。首先介紹了ADIS16350的SPI接口及其工作時序,然后給出SPI與RS 232接口轉換電路設計方案,及用Verilog HDL語言,采用模塊化編程方式在FPGA內實現2種接口的通信時序和數據交換。最后通過軟件仿真和硬件實物調試,驗證了該方案通信簡潔、可靠,具有較廣泛的實用價值。關鍵詞:SPI接口; FPGA; Verilog HDL語言; RS 232接口; MEMS
中圖分類號:TN919-34文獻標識碼:A
文章編號:1004-373X(2010)18-0145-03
Design and Implementation of MEMS Sensor ADIS16350's Interface Conversion
TANG Xia-qing1, YAN Chang-ping1, LIU Pei2
(1.Armored Force Engineering Institute, Beijing 100072, China;2.Beijing Special Vehicle Institute, Beijing 100072, China)
Abstract: A method to implement the conversion between SPI interface and RS-232 interface based on FPGA is proposed. At first,the SPI interface and working time-sequence of ADIS16350 is introduced,then, the design scheme of the interface conversion circuit ispresented. Using Verilog HDL language and modularize programming method, the communication of two interface and data exchange have been accomplished within FPGA, the result of simulation and hardware test show that the proposed method is simple, reliable and worthy of using widely.
Keywords: SPI interface; FPGA; Verilog HDL language; RS-232 interface; MEMS
0 引 言
ADIS16350是集三軸陀螺和加速度計于一體的MEMS傳感器,其SPI接口和簡單的輸入/輸出寄存器結構提供了簡易的姿態信息讀取和工作方式配置的方法。SPI是由Motorola公司推出的一種四線制同步串行接口,其具有傳送速率高及良好的擴展性等優點,但非PC標配接口,使其應用受限。
而RS 232接口是目前最為常用的一種串行通信接口,也是PC的標配接口,其簡易模式為兩線制,應用相當廣泛。本文采用基于FPGA的轉換電路,設計與實現了SPI接口與RS 232接口的轉換,使PC通過上位機軟件完成對ADIS16350的配置和姿態信息的讀取。
1 ADIS16350的SPI接口及時序
ADIS16350中SPI接口包括4根信號線:片選使能(CS)、串行時鐘(SCLK)、數據輸入(DIN)及數據輸出(DOUT)。SPI接口一個完整的數據結構為16個時鐘周期,是一種全雙工接口,讀、寫數據在時鐘上升沿有效。它包括以下2種模式:
(1) 一種是配置模式,通過寫命令配置控制寄存器,以初始化ADIS16350的自校準、測量范圍、采樣頻率等。配置一個完整的16位命令時,需2個完整的數據結構。其時序如圖1所示。
圖1 配置模式時序圖
(2) 另一種是讀取模式,通過寫入讀取地址,獲取對應ADIS16350測量的角速率、加速度或陀螺溫度等姿態信息。……