SPI Master controller implementation on FPGA using vhdl
March 18, 2017 | Author: Anand Cool | Category: N/A
Short Description
Download SPI Master controller implementation on FPGA using vhdl...
Description
Date: 10-11-2012
Internship Under Dr. Subhajit Roy Chowdhury Guided By LVRama Prasada Raju
SPI_Master_Programming
1
INDEX
1. Introduction and block diagram of SPI
3
2. Specifications of ADS1299
4
3. Applications of ADS1299
5
4. Architecture of ADS1299
5
5. PIN specifications of SPI
6
6. Calculations
7
7. Operation
8
8. Flow chart for Master Device
9
9. State machine of master device
10
10. master device program in VHDL
11
2
SPI(serial peripheral interface) controller
1.INTRODUCTION:The Serial Peripheral Interface bus is a synchronous serial data link standard, named by Motorola, that operates in full duplex mode. Devices communicate in master/slave mode where the master device initiates the data frame. Multiple slave devices are allowed with individual slave select (chip select) lines. Sometimes SPI is called a four-wire serial bus, contrasting with three-, two-, and one-wire serial buses. SPI is often referred to as SSI (Synchronous Serial Interface).
The basic block diagram of SPI is shown here
Fig.1 Basic SPI block diagram SPI mainly contains four basic signals >MOSI (master out, slave in) >MISO(master in , slave out) >SS(slave select or enable) >SCLK(slave or clock)
3
Since SPI is a full duplex communication it requires two bus lines. MOSI bus is required to send data from master to slave device. MISO bus is required to send data from slave device to master. And SS pin is used to select the slave device and SCLK is the spi clock pulse. Here we are developing the SPI master device for the ADS1299 slave as reference slave device. The ADS1299 is a 24-bit ADC(Analog to Digital convertor) from the TI (Texas Instrumentation ) industry. 2.Specifications of ADS1299 are as follows >Eight Low-Noise PGAs and Eight High-Resolution Simultaneous-Sampling ADCs >Low Power: 5 mW/channel >Input Bias Current: 300 pA >Data Rate: 250 SPS to 16 kSPS >CMRR: –110 dB > Programmable Gain: 1, 2, 4, 6, 8, 12, or 24 >Unipolar or Bipolar Supplies: – Analog: 4.75 V to 5.25 V – Digital: 1.8 V to 3.6 V >Built-In Oscillator >Internal or External Reference >Flexible Power-Down, Standby Mode >SPI™-Compatible Serial Interface >Operating Temperature Range: –40°C to +85°C
4
3.APPLICATIONS • Medical Instrumentation (EEG and ECG) Including: – EEG, Bispectral index (BIS), Evoked audio potential (EAP), Sleep study monitor • High-Precision, Simultaneous, Multichannel Signal Acquisition
4.The Architecture of ADS1299 is shown below
Fig.2 ADS1299 architecture
5
It has 8 input analog channels, each having both positive and negative inputs. Each analog signal is modulated and encoded as 24-bit data. It operates at maximum of 2.048MHz speed. So that it can modulate in the range of 250SPS to 16kSPS (samples per second). The data will be transferred to any master device by SPI interface with control signals. The more explanation about the architecture can be found in ADS1299 datasheet… DRDY (DATA ready) bar signal indicates the data is ready in the slave buffer, that means the conversion has been finished and the slave buffer is filled with 24-bits. PWDN bar is a power down signal active low. It is used to power down the device. START signal is active high signal. When it is connected to logic-‘1’ the ADC conversion will starts. 5.Pins used in the communication DRDY_bar = generated by slave device GPIO-(4 to 1)= These are not used CLK = generated by internal oscillator of ADS1299 SCLK = it is generated by Master device CLKSEL = clock select signal of ADS1299. Will be connected to 0v to select internal clock oscillator. DIN = Data input from the Master device (MOSI) DOUT = Data output from the slave device (MISO) PWDN_bar= used by ADS1299 and is connected to logic ‘1’ to discard the signal START = used by ADS1299. Connected to logic ‘1’ always to start ADC conversion CS_bar = used by ADS1299 and generated by Master device RESET_bar=active low, used by slave device. Is connected using switch.
6
6.Calculations: Choosing of the slave clock SCLK depends on different parameters. The following formula determines the slave clock period required for the chosen parameters.
Where tSCLK= slave clock period
tDR= data rate (fdr range 250 sps-to-16kSPS) NBITS= ADC resolution (number of bits per sample) NCHANNELS=number of analog channels present in the device When we choose 925 SPS data rate the tsclk will be (1/900)-4(1/2.048x10^-6)
tsclk <
------------------------------------24x 8+24
tsclk < Fsclk >
5.134990676 x 10^-6 194.742 KHz
thus we are choosing the slave clock frequency greater than 194KHz i.e. we can choose 200KHz frequency when the sampling rate is 900 SPS. The minimum possible Fsclk slave clock frequency is 100KHz.
7
The master device will be implemented on FPGA. The master will be coded as it should compatible with ADS1299 data converter SPI. While interfacing ADS1299 to the master device the slave device should be preprogrammed so that its internal register can load its appropriate values.
7.Operation:The Timing Diagram explains the operation of the master slave communication
Fig.3 Timing Diagram of SPI We have chosen the maximum clock frequency as the master clock frequency i.e., 2.048MHz. And the slave clock becomes 200KHz. The master device will communicate with the slave device whenever it receives either DRDY bar (Data ready ) signal from the slave device that it indicates the data is ready to transmit to the master or when the master device wants to communicate with slave device it generates Transmit buffer full (Tx_BUFF_FULL) signal which is active high. The master will also generates the chip select signal when it receives the Tx_BUFF_FULL and the device select signal. When master receives the DRDY active low signal from the corresponding slave device it generates the chip select (CS_bar) signal as active low for the duration of 24 clock cycles i.e., until the data transmission completed. Here the master and slave devices are connected in a standard fashion so that DAISY_IN signal will not be used. Here we designed the master device to communicate with one slave device. We can improve it communicate with more slaves by adding extra signals.
8
8.Flow Chart:-
Start
Send SCLK
NO Tx_BUFF=” 0”
YES Tx_BUFF_FULL=’1’
Tx_BUFF_FULL=0
Rising_edg e(clk)
CS_bar=’1 ’
YES YES
DRDY=’0’ or Tx_BUFF_FULL=1
For I in 23 downto 0 loop CS_bar=’0’; MOSI=S_buff(23);
NO
NO
S_buf(23 dwto10)=s_buf(22 dwto 0) S_buf(0)=MISO Rx_buff=S_buf S_buf=Tx_buff 9
9.STATE_MACHINE of MASTER DEVICE:-
Entity : spi Architecture: spi r T x_BUFF_FULL
r Rx_BUFF[23:0]
m osi CS_bar
r T x_BUFF[23:0]
r INT _bar
r S_BUFF[23:0]
m iso clk
sclk
Sreg0 clk ce
No clock enable
S2 /010/ S3 Tx_BUFF="0000000000000000" T x_BUFF_FULL
View more...
Comments