ADS1255 (24-bit ADC) Initialisation command sequence

Hi friends, I am working on 16 - channel data acquisition project, Silab C8051F310

  • ADS1255 + external multiplexer.

ADC crystal is 7.643 MHz. SPI clock freq is 1.58 MHz

Hardware interface- CS --> permanently tied to ground 3 wire SPI (SCK, MOSI, MISO) DRDY as external interrupt source

When I debug the code by step by step it works most of the time. But in normal case it does not.

Whether my command sequence or delay between command is wrong. Or something else i am missing.

Source code

/** * @brief Write data to ADS1255 registers at specified address \a lbAddress * of specified length \a lbLength from pointer \a lpSource. * * @param lbLength - Specifies the number of Bytes to write * @param lbAddress - Specifies the destination ADS1255 register address * @param lpSource - Byte pointer to write data to ADS1255 * */ void Wr_ADS1255_Reg ( Byte lbLength, Byte lbAddress, Byte * lpSource ) { SELECT_ADS1255(); // Select ADS1255

SPI_Write ( 0x50 | lbAddress ); // Address with Write command SPI_Write ( lbLength - 1 ); // No of registers to write

do { SPI_Write ( *lpSource++ ); // Write the data } while ( --lbLength );

Wait_Clk ( 16 ); // Wait for 16 clock }

/** * @brief Read data from ADS1255 registers from specified address \a lbAddress * of specified length \a lbLength to pointer \a lpDest * * @param lbLength - Specifies the number of Bytes to read * @param lbAddress - Specifies the address of ADS1255 register * @param lpDest - Byte pointer to store data from ADS1255 * */ void Rd_ADS1255_Reg ( Byte lbLength, Byte lbAddress, Byte * lpDest ) { SELECT_ADS1255(); // Select ADS1255

SPI_Write ( lbAddress | 0x10 ); // Write Address with read command

SPI_Write ( lbLength - 1 ); // No of registers to read

Wait_Clk ( 80 ); // Wait for 80 clock

do { *lpDest++ = SPI_Read(); // Read data from ADS1255 } while ( --lbLength );

Wait_Clk ( 16 ); // Wait for 16 clock

}

void Init_ADS1255 ( void) {

SELECT_ADS1255();

Send_SPI ( enWAKEUP ); // Wakeup the Ads1255. Wait_Clk ( 48 ); // Wait for 48 clocks

Send_SPI ( enRESET ); // Reset the ADS1255. Wait_Clk ( 48 ); // Wait for 48 clocks

// Read the registers to verify the communication Rd_ADS1255_Reg ( sizeof ( stRdReg ), 0, ( Byte * ) &stRdReg );

stWrReg.Status = 0x04; // Auto calibration is enabled stWrReg.MUX = 0x08; // Single ended channel 0 stWrReg.ADCON = 0; stWrReg.IO = 0xE0; // IO register stWrReg.DRate = 0xF0; // 30K SPS

Wr_ADS1255_Reg ( 5, 0, ( Byte * ) &stWrReg );

SPI_Write ( enSYNC ); // Syncronize the ADC

SPI_Write ( enWAKEUP ); // Wakeup the Adc

Rd_ADS1255_Reg ( sizeof ( stRdReg ), 0, ( Byte * ) &stRdReg );

SPI_Write ( enSELFCAL ); // perform Self calibration

}
Reply to
kishor
Loading thread data ...

First, without more detail on what you mean when you say "works" or "doesn't work", it will be hard for anyone to offer any specific recommendations. What do you expect to happen when it works? What do you observe that leads you to conclude that it isn't working?

Based on your report that it works (mostly) when you step through the code with your debugger, it sounds like a timing issue to me. These can be extremely difficult to diagnose because you are attempting to examine in seconds or tens of seconds events that occur in microseconds.

At this point I'd suggest that you re-read the ADC datasheet carefully with special attention to minimum and maximum timings. Your debugger slows down the CPU's actions relative to the ADC, so I'd start with the minimum timings and check them against your hand-calculated instruction timings for your '8051 code.

Good luck!

Frank McKenney

-- Youth is much more capable of amusing itself than is now supposed, and in much less mortal need of being amused. The only real warning against solitude and stagnation which needs to be uttered is that you really need to be rather young and strong in order to get the fun out of them. -- G.K. Chesterton: On the Thrills of Boredom (1932)

-- Frank McKenney, McKenney Associates Richmond, Virginia / (804) 320-4887 Munged E-mail: frank uscore mckenney ayut mined spring dawt cahm (y'all)

Reply to
Frnak McKenney

That's _wrong_. SPI uses edges of the CS line to signal the beginning of a transaction. It can't work without it.

Reply to
Hans-Bernhard Bröker

The OP needs to re-visit the data sheet. TI do offer a mode of operation for this part with CS tied to ground but of course it's not SPI - it's a two wire mode with DataIn and DataOut on th same pin and not all the chip functions are supported.

Since the Silab part has proper SPI why not use it ?

Michael Kellett

Reply to
MK

ess \a

ter \a lpSource.

ister

=A0 =A0 =A0 =A0 =A0 // Select ADS1255

=A0 =A0 // Address with Write command

=A0 =A0 =A0 // No of registers to write

=A0 =A0 =A0 =A0// Write the data

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0// Wait for 16 clock

ddress \a

r \a lpDest

ster

=A0 // Select ADS1255

Address with read command

of registers to read

=A0 =A0 =A0 =A0 =A0 =A0// Wait for 80 clock

// Read data from ADS1255

=A0 =A0 =A0 =A0 =A0 =A0// Wait for 16 clock

ds1255.

=A0 =A0 =A0 =A0 =A0 =A0// Wait for 48 clocks

// Reset the ADS1255.

=A0 =A0 =A0 =A0 =A0 =A0// Wait for 48 clocks

eg );

ration is enabled

=A0 // Single ended channel 0

=A0 =A0 // IO register

=A0 // 30K SPS

=A0 =A0 =A0 =A0 // Syncronize the ADC

/ Wakeup the Adc

eg );

/ perform Self calibration

Since it works while you go in slowly, it should be a delay factor that is affecting the operation.

Just as other pointed out, it would be better if you are clear of the operation from the datasheet.

BR, Karthik Balaguru

Reply to
karthikbalaguru

I would just mention I had trouble using the 'F064 SPI in 4 wire master mode using NSSMD0, but all worked well using three wire mode and another port pin for CS.

Reply to
Bill Davy

Hi friends,

As all of u mentioned, I concentrated on "timing issues". I set the delay of 500 micro-seconds before "Read register command".

This works, I got the valid readings.

But still this is strange......, cause according to data sheet delay should be 4 micro-seconds.

As the initialization is performed in once only (at starting), It will not affect my ADC data scanning rate.

all other commands are working properly.

Thanks & regards, Kishore.

Reply to
kishor

That's a _long_ time, even in "microcontroller years".

But "working" is always better than "non-working".

Always a desirable outcome.

This sounded very fast for a complex chip startup, so I checked The Datasheet. Under POWER-UP we see this:

"... A self-calibration is then performed automatically. For best performance, it is strongly recommended to perform an additional self-calibrarion by issuing the SELFCAL command after the power supplies and voltage reference have had time to settle to their final value."

Then, under SELFCAL:

"/DRDY goes high at the beginning of the calibration. It goes low after the calibration completes and settled data is ready. Do not send additional commands after issuing this command until /DRDY goes low indicating that the calibration is complete."

It is not clear whether the "automatic" calibration is exactly the same as SELFCAL, but it should raise a red (warning) flag as you read it, especially when you noice from Table 21 that SELFCAL takes

600usec-1227msec to complete. That's 1227000usec; we're talking microcontroller _centuries_ here.

It's also not stated in the datasheet (or I missed it) whether /DRDY can be used to check whether the _automatic_ RESET/power-up self-calibration has completed, but if I were writing the code I'd give it a try. Using fixed timing to work around an unknown problem would make me uncomfortable; your 500usec seems marginal (per Table

21); timings can change, and changing them is one of "Murphy's" favorite pastimes.

Good signs.

Best of luck.

Frank

--
    Of all tyrannies, a tyranny sincerely exercised for the good of
    its victims may be the most oppressive. It may be better to live
    under robber barons than under omnipotent moral busybodies.
    The robber baron's cruelty may sometimes sleep, his cupidity may
    at some point be satiated: but those who torment us for our own
    good will torment us without end, for they do so with the
    approval of their own conscience.     -- C. S. Lewis
Reply to
Frnak McKenney

Hi Frank,

Thanks, you pointed out very important thing.

Now Instead of blind "500 micro-seconds" delay I am monitoring DRDY line, after "RESET" & "Write reg" command.

This approach will make my code more "Reliable" & "Predictable".

Thanks & regards, Kishore.

Reply to
kishor

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.