MAX1416 16 Bit A/D troubles
I am having trouble setting up the registers for this A/D using the SHIFTOUT Command.
I am using the following Basic Setup flow on Page 29 of the DataSheet :
http://datasheets.maxim-ic.com/en/ds/MAX1415-MAX1416.pdf
The Datasheet specifies MSBFIRST and the·allowable Clkin Freq·is 400KHz to 2.5Mhz·so I
setup the "SpeedMulti" constant to 10 (10x83Khz = 830 Khz)
I am thinking its the way Im sending the data to the SPI interface because
I cannot get the /DRDY (Data Ready) pin to go LOW.
Has anyone used this 16Bit A/D before with the SX? Any help is appreciated.
Below is a sample of my code.
Thanks
DEVICE ··SX28, OSCHS3, TURBO, STACKX, OPTIONX
FREQ ··50_000_000
Dout · ·PIN ·RB.0 OUTPUT·········· ' Data TO MAX1416 (DIN) Pin 14
Cpin ·· PIN ·RB.2 OUTPUT··········· ' SCLK to MAX1416 (SCLK)Pin 1
Din···· PIN·RB.1 INPUT················· ·' Data from MAX1416 (DOUT) Pin 13
TX····· ·Pin···· RA.0 output·' Serial to PC
Baud··CON·"T9600"··' BAUD for PC
ComRegWRClk···· CON·%00100000·············· ··· ·'$20··' CH1 ; Set Operation WR to Clock REG
ClkRegWR·········· CON·%10100101··················· '$A5· ' INTCLK Frq 2.4576Mhz ; 60HZ Update
ComRegWRSetup· CON·%00010000··················· ·'$10·' Set Operation WR to Setup REG
ComWRSetup······ CON·%01000100···················· '$44·' SelfCal ; Gain 0 ; UniPolar ; NoBuf ; Beg SelfCal Clear FSYNC
ComWRComReg···· CON·%1000························· ·'$08·' Set Operation Read from ComReg to see if DATA is ready!
DataVar·············· VAR·Byte···························· 'VAR for ShiftOutIn Command
TX_BYTE·SUB 1
PROGRAM Start
Start:
Main:
pause 1000
SHIFTOUT Dout, Cpin, MSBFIRST,· ComRegWRClk,10
SHIFTOUT Dout, Cpin, MSBFIRST,· ClkRegWR,10
SHIFTOUT Dout, Cpin, MSBFIRST,· ComRegWRSetup,10
SHIFTOUT Dout, Cpin, MSBFIRST,· ComWRSetup,10
SHIFTOUT Dout, Cpin, MSBFIRST,· ComWRComReg,10
SHIFTIN Din, Cpin, MSBPOST, DataVar,10
'TX_BYTE DataVar
SEROUT TX, Baud, DataVar
SEROUT TX, Baud, "M"
goto Main
SUB TX_BYTE
· SEROUT TX, Baud, __PARAM1
ENDSUB
I am using the following Basic Setup flow on Page 29 of the DataSheet :
http://datasheets.maxim-ic.com/en/ds/MAX1415-MAX1416.pdf
The Datasheet specifies MSBFIRST and the·allowable Clkin Freq·is 400KHz to 2.5Mhz·so I
setup the "SpeedMulti" constant to 10 (10x83Khz = 830 Khz)
I am thinking its the way Im sending the data to the SPI interface because
I cannot get the /DRDY (Data Ready) pin to go LOW.
Has anyone used this 16Bit A/D before with the SX? Any help is appreciated.
Below is a sample of my code.
Thanks
DEVICE ··SX28, OSCHS3, TURBO, STACKX, OPTIONX
FREQ ··50_000_000
Dout · ·PIN ·RB.0 OUTPUT·········· ' Data TO MAX1416 (DIN) Pin 14
Cpin ·· PIN ·RB.2 OUTPUT··········· ' SCLK to MAX1416 (SCLK)Pin 1
Din···· PIN·RB.1 INPUT················· ·' Data from MAX1416 (DOUT) Pin 13
TX····· ·Pin···· RA.0 output·' Serial to PC
Baud··CON·"T9600"··' BAUD for PC
ComRegWRClk···· CON·%00100000·············· ··· ·'$20··' CH1 ; Set Operation WR to Clock REG
ClkRegWR·········· CON·%10100101··················· '$A5· ' INTCLK Frq 2.4576Mhz ; 60HZ Update
ComRegWRSetup· CON·%00010000··················· ·'$10·' Set Operation WR to Setup REG
ComWRSetup······ CON·%01000100···················· '$44·' SelfCal ; Gain 0 ; UniPolar ; NoBuf ; Beg SelfCal Clear FSYNC
ComWRComReg···· CON·%1000························· ·'$08·' Set Operation Read from ComReg to see if DATA is ready!
DataVar·············· VAR·Byte···························· 'VAR for ShiftOutIn Command
TX_BYTE·SUB 1
PROGRAM Start
Start:
Main:
pause 1000
SHIFTOUT Dout, Cpin, MSBFIRST,· ComRegWRClk,10
SHIFTOUT Dout, Cpin, MSBFIRST,· ClkRegWR,10
SHIFTOUT Dout, Cpin, MSBFIRST,· ComRegWRSetup,10
SHIFTOUT Dout, Cpin, MSBFIRST,· ComWRSetup,10
SHIFTOUT Dout, Cpin, MSBFIRST,· ComWRComReg,10
SHIFTIN Din, Cpin, MSBPOST, DataVar,10
'TX_BYTE DataVar
SEROUT TX, Baud, DataVar
SEROUT TX, Baud, "M"
goto Main
SUB TX_BYTE
· SEROUT TX, Baud, __PARAM1
ENDSUB
Comments
I don't see you using a pin for chip select, I believe that is pin 4. You must take CS low before you can address the chip. Next Jonny mac gave me a clue in programing for an ADC and that was use a command of clock = 0 before you start getting information to and from the ADC the following is the func code that works for me.
'
' Read the Analog/digital converter
ADC_CS PIN OUTPUT
ADC_CLK PIN OUTPUT
ADC_DIO PIN INPUT PLP
Func READ_ADC
low ADC_CS
ADC_CLK = 0
NOP
SHIFTIN ADC_DIO,ADC_CLK,MSBPOST,tmpB1\9,4
high ADC_CS
tmpW1_msb = 0
tmpW1_lsb = tmpB1
Return tmpW1
ENDFUNC
I had no luck with it until I put the clock = 0 after the Chip select low.
maybe this will help!
RS_Jim
I am using 3wire mode with CS tied to GND. I tried Clk = 0 as you suggested before I started
to program the 1st Register but it didnt work.
Did you use a MAX1416?
I believe you are getting the SHIFTOUT frequency of the SX/B command mixed up with the CLKIN frequency stated in the data sheet. The data sheet states CLKIN is either connected to a crystal/resonator between CLKIN and CLKOUT, or with a CMOS-compatible clock source. Also, the CLKIN can be connected to GND when using the internal oscillator. This is found on page 18 of the data sheet. Also, pay attention to Note 15 on page 9. This is in reference to the CLKIN.
According to timing characteristics found on page 8, the maximum speed of the serial clock is 5 MHz (1/100nS SCLK LOW + 1/100nS SLCK HIGH). There is no minimum speed specified for the SCLK.
Gary
Thanks for the clarification. I found out my problem .... I left the RESET pin floating, after I tied it to GND DRDY was going LOW like it should.
I am now in the process of using the example TX_BYTE subs with the SHIFTIN command to read the data on my terminal.
Thanks
mikey