Features
• 10-bit resolution
• ±1 LSB max DNL
• ±1 LSB max INL
• Analog inputs programmable as single-ended or
pseudo-differential pairs
• On-chip sample and hold
• SPI™ serial interface (modes 0,0 and 1,1)
• Single supply operation: 2.7V - 5.5V
• 200 ksps max sampling rate at VDD = 5V
• 75 ksps max sampling rate at VDD = 2.7V
• Low power CMOS technology:
- 5 nA typical standby current, 2 µA max
- 550 µA max. active current at 5V
• Industrial temp range: -40°C to +85°C
• 8-pin MSOP, PDIP, SOIC and TSSOP packages
Applications
• Sensor Interface
• Process Control
• Data Acquisition
• Battery Operated Systems
源自於
https://gist.github.com/jjcarrier/2590356
module adc(clk, cs, clk_1_20, dout, din);input clk; //p181output cs; //p22output clk_1_20; //p24input dout; //p26output din; //p28wire clk;wire dout;reg clk_1_20;reg din;reg cs;//----------------------------------------------------//First generate the 1.2MHz clock from the 24MHz clock//To do this we must create a counter that counts to 20reg [4:0] cnt20; //This will create 32 values but we only want 20reg [4:0] cnt20_next;//Lets create the top level state update to cnt20always @(posedge clk) cnt20<=cnt20_next;//Lets create a simple process to limit this rangealways @(posedge clk)beginif (cnt20==20)begincnt20_next<=0; //Reset to zeroclk_1_20<=~clk_1_20; //Flip the state of clk_1_20endelsebegincnt20_next<=cnt20_next+1; //Continue with incrementclk_1_20<=clk_1_20; //Maintain the state of clk_1_20endend//----------------------------------------------------//In this code we will be using both the positive and negative edge//of the clk_1_20 signal. The order that these processes execute are important//because of this we need to ensure that the negative edge processes start//before the postive edge processes. To do this we must create a latch signal.reg init_latch;always @(posedge clk_1_20) init_latch<=1;//----------------------------------------------------//Now that we have the 1.2MHz clock, we can generate//another counter that counts to 16 at 1.2MHzreg [3:0] cnt16;always @(posedge clk_1_20) if (init_latch==1) cnt16<=cnt16+1;//----------------------------------------------------//Lets also create a channel selection bit//This bit will flip after each sample has been acquiredreg channel;always @(negedge clk_1_20) if (init_latch==1) if (cnt16==15) channel<=~channel; else channel<=channel;//----------------------------------------------------//With the newly created counter, cnt16,//we can now create the 16 step SPI//The input signals to the SPI should operate on the negative edge//This is because the SPI on the ADC samples on the positive edge//We want to maximize the settling time of the signal as to avoid//communication errorsalways @(negedge clk_1_20)beginif (init_latch==1)begincase (cnt16)0://Bring cs high to initializebegincs<=1;din<=0;end1://START BIT :: Bring cs low and din high to initiate communicationbegincs<=0;din<=1;end2://MODE BIT :: Bring din high to set the mode to single-endedbegincs<=0;din<=1;end3://CHANNEL BIT :: Bring din low to select channel 0begincs<=0;din<=0; //channel;end4://MSBF BIT :: Bring din high to set the output in MSB First formatbegincs<=0;din<=1;end5://Maintain cs low for the remainder of the 16 clocksbegincs<=0;din<=0;end6://Maintain cs low for the remainder of the 16 clocksbegincs<=0;din<=0;end7://Maintain cs low for the remainder of the 16 clocksbegincs<=0;din<=0;end8://Maintain cs low for the remainder of the 16 clocksbegincs<=0;din<=0;end9://Maintain cs low for the remainder of the 16 clocksbegincs<=0;din<=0;end10://Maintain cs low for the remainder of the 16 clocksbegincs<=0;din<=0;end11://Maintain cs low for the remainder of the 16 clocksbegincs<=0;din<=0;end12://Maintain cs low for the remainder of the 16 clocksbegincs<=0;din<=0;end13://Maintain cs low for the remainder of the 16 clocksbegincs<=0;din<=0;end14://Maintain cs low for the remainder of the 16 clocksbegincs<=0;din<=0;end15://Maintain cs low for the remainder of the 16 clocksbegincs<=0;din<=0;endendcaseendend//----------------------------------------------------//Now that the input into the ADC's SPI has been created//we can now grab the output//First create the sample signal which will act as a 10-bit FIFOreg [9:0] sample;//----------------------------------------------------//Now with the sample signal created, start sampling dout//The output is only valid on clock 6-15//This data should be grabbed on the positive edge so that//the ADC's output has time to settle//always @(posedge clk_1_20)beginif (init_latch==1)beginif (cnt16>=6)beginsample[9:1]<=sample[8:0];sample[0]<=dout;endelse sample<=sample;endendendmodule
沒有留言:
張貼留言