This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADS1248: Reading data from ADS1248

Other Parts Discussed in Thread: ADS1248, TEST2

art Number: ADS1248

Hi Team,

In my project I am using two RTDS with ADS1248 for temperature measurement. I am attaching two files with this. In SPI_Test1.c I wrote the SPI communication initialization and reading back from ADS1248 in the same main loop. Now to give an order to my main program I decided to rewrite the main code with all initialization routine as one group and signal readings in other. As a part of it I split my SPI_Test1.c as seen in SPI_Test2.c. I am using a 100 ohm fixed resistance across first channel AIN0-3 for ratiometric measurement. When ran the first code code I got an output code value equal '6217209' which is correct value. But when I ran the same code split into functions as seen in SPI_Test2.c some times I get nothing on first reading, sometimes I get the correct value and some times I get code equal to '8388607, which I think FSR. Why this happens? 

Is it possible to keep START pin continuously HIGH so that the device goes on converting and read data at required times with RDATA command without monitoring DRDY pin?

Thank you,

Vineeth N

SPI_Test1.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//*****************************************************************************
// FILE NAME : C_138 SPI loop back Test.c
// DATE : 20.05.2020
// AUTHORS : Vineeth N
// DESCRIPTION : FOR TESTING SPI OF C_138 USING RTD
// CONTROLLER CARD : Contoller 138 control Board
//******************************************************************************
/* EXTERNAL CRYSTAL FREQUENCY 20MHz
*******************************************************************************/
//-----------------------------------------------------------------------------
// Include Header Files
// ----------------------------------------------------------------------------
#include"F28x_Project.h"
void main(void)
{
// Intiate system controls, GPIO pins, interrupt
uint32_t r1 = 0x00000000;
uint16_t r2 = 0x0000;
uint32_t r3 = 0x0000000;
InitSysCtrl();
InitGpio();
EALLOW;
GpioCtrlRegs.GPAGMUX1.bit.GPIO9 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 3; // set Gpio pin 9 as SPI clock pin
GpioCtrlRegs.GPAPUD.bit.GPIO9 = 0; // Pull up enable
GpioCtrlRegs.GPAQSEL1.bit.GPIO9 = 3; // Qualifier Selection
GpioCtrlRegs.GPAGMUX1.bit.GPIO8 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO8 = 3; // set Gpio pin 8 as SPI SIMO pin
GpioCtrlRegs.GPAPUD.bit.GPIO8 = 0; // Pull up enable
GpioCtrlRegs.GPAQSEL1.bit.GPIO8 = 3; // Qualifier Selection
GpioCtrlRegs.GPAGMUX1.bit.GPIO10 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO10 = 3; // set Gpio pin 10 as SPI SOMI pin
GpioCtrlRegs.GPAPUD.bit.GPIO10 = 0; // Pull up enable
GpioCtrlRegs.GPAQSEL1.bit.GPIO10 = 3; // Qualifier Selection
GpioCtrlRegs.GPAGMUX1.bit.GPIO14 = 0;
GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 0; // set Gpio pin 14 as GPIO output pin (CS/)
GpioCtrlRegs.GPADIR.bit.GPIO14 = 1; // set direction as output
GpioCtrlRegs.GPAGMUX1.bit.GPIO15 = 0;
GpioCtrlRegs.GPAMUX1.bit.GPIO15 = 0; // set Gpio pin 15 as GPIO output pin (START)
GpioCtrlRegs.GPADIR.bit.GPIO15 = 1; // set direction as output
GpioCtrlRegs.GPBGMUX1.bit.GPIO34 = 0;
GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0; // set Gpio pin 34 as GPIO output pin (ADC_RST)
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; // set direction as output (ADC_RST)
GpioCtrlRegs.GPAGMUX1.bit.GPIO6 = 0;
GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 0; // set Gpio pin 6 as GPIO input pin (IRQ_3)
GpioCtrlRegs.GPAPUD.bit.GPIO6 = 0; // Pull up enable
EDIS;
GpioDataRegs.GPASET.bit.GPIO14 = 1; // Clear CS/ pin to high
GpioDataRegs.GPACLEAR.bit.GPIO15 = 1; // ADC_RST held low
GpioDataRegs.GPBCLEAR.bit.GPIO34 = 1; // START pin held low
SpiaRegs.SPICCR.bit.SPISWRESET = 0; // clear software reset bit
SpiaRegs.SPICTL.bit.MASTER_SLAVE = 1; // master mode selected
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

SPI_Test2.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//*****************************************************************************
// FILE NAME : C_138 SPI loop back Test.c
// DATE : 20.05.2020
// AUTHORS : Vineeth N
// DESCRIPTION : FOR TESTING SPI OF C_138 USING RTD
// CONTROLLER CARD : Contoller 138 control Board
//******************************************************************************
/* EXTERNAL CRYSTAL FREQUENCY 20MHz
*******************************************************************************/
//-----------------------------------------------------------------------------
// Include Header Files
// ----------------------------------------------------------------------------
#include"F28x_Project.h"
void config(void);
void spi(void);
void read(void);
uint32_t r1 = 0x00000000;
uint16_t r2 = 0x0000;
uint32_t r3 = 0x0000000;
void main(void)
{
// Intiate system controls, GPIO pins, interrupt
InitSysCtrl();
InitGpio();
EALLOW;
GpioCtrlRegs.GPAGMUX1.bit.GPIO9 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 3; // set Gpio pin 9 as SPI clock pin
GpioCtrlRegs.GPAPUD.bit.GPIO9 = 0; // Pull up enable
GpioCtrlRegs.GPAQSEL1.bit.GPIO9 = 3; // Qualifier Selection
GpioCtrlRegs.GPAGMUX1.bit.GPIO8 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO8 = 3; // set Gpio pin 8 as SPI SIMO pin
GpioCtrlRegs.GPAPUD.bit.GPIO8 = 0; // Pull up enable
GpioCtrlRegs.GPAQSEL1.bit.GPIO8 = 3; // Qualifier Selection
GpioCtrlRegs.GPAGMUX1.bit.GPIO10 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO10 = 3; // set Gpio pin 10 as SPI SOMI pin
GpioCtrlRegs.GPAPUD.bit.GPIO10 = 0; // Pull up enable
GpioCtrlRegs.GPAQSEL1.bit.GPIO10 = 3; // Qualifier Selection
GpioCtrlRegs.GPAGMUX1.bit.GPIO14 = 0;
GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 0; // set Gpio pin 14 as GPIO output pin (CS/)
GpioCtrlRegs.GPADIR.bit.GPIO14 = 1; // set direction as output
GpioCtrlRegs.GPAGMUX1.bit.GPIO15 = 0;
GpioCtrlRegs.GPAMUX1.bit.GPIO15 = 0; // set Gpio pin 15 as GPIO output pin (START)
GpioCtrlRegs.GPADIR.bit.GPIO15 = 1; // set direction as output
GpioCtrlRegs.GPBGMUX1.bit.GPIO34 = 0;
GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0; // set Gpio pin 34 as GPIO output pin (ADC_RST)
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; // set direction as output (ADC_RST)
GpioCtrlRegs.GPAGMUX1.bit.GPIO6 = 0;
GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 0; // set Gpio pin 6 as GPIO input pin (IRQ_3)
GpioCtrlRegs.GPAPUD.bit.GPIO6 = 0; // Pull up enable
EDIS;
config();
spi();
for(;;)
{
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  

  • Hi Vineeth,

    This is acceptable, however it sounds like there may be a timing mismatch when you sometimes send SCLKs to retrieve data. If you do not monitor the DRDY pin, inevitably, there will be a small timing mismatch that leads to "drift" in terms of when you are taking the data. Eventually, this will lead to truncated samples - which it sounds like is what you are seeing. We typically recommend monitoring DRDY for this reason. 

  • Hi Alex,

    Thank you for your response. My aim is to read the result from ADC in every 20 ms interval. I have three other ADCs in my circuit. Total run time of the main loop is limited to 20 us. This is why I split up the ADC code to initialization part and signal read part,  so that only signal reading part will be active in main loop. This was my idea. Considering this idea can you please give me a suggestion how I can accomplish this with monitoring DRDY pin.

    I have a doubt that if I am not monitoring DRDY pin but still reading conversion results, it should give me last stored conversion result instead of some junk value, right? 

    I have tried pulsing the START pin with a 1 us positive pulse to obtain single conversion at a time. Since it is a single conversion I think the data on result register will not change. Am I reading this correct? If that is the case after pulsing START if I read result I should get proper value. With this method also I am getting same wrong values around around 8388607.

    How to do single conversions with thios ADC?. I can't do it with SLEEP and WAKEUP commands because I can't keep CS/ low all the time, Since I have other SPI ADCs .

    Thank you,

    Vineeth N

  • Hi Vineeth,

    If you take a look at the command table Table 19. SPI Commands for reference. Upon power-up and initialization, I would recommend issuing an SDATAC command in order to stop continuous conversions. Then, you can simply use the RDATA command to read data once from each ADC every time you loop. This way you can leave the START pin HIGH. 

    Yes, however if you are in the middle of reading a result, then a new conversion becomes ready, the read result will be corrupted as it will be composed of two different read results.

    You must wait at least 3tclk after pulling START high to begin reading - it is possible that the timing is being violated.