cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Discovery with ADS7870 (TI) ADC

camila
Associate II
Posted on January 15, 2014 at 10:19

Hi,

I'm trying to communicate between the

http://www.ti.com/product/ADS7870

and the ST microcontroller STM32F4 Discovery evaluation board. I'm using IAR and at the moment I'm just trying to read register 31 from the ADC (which should return a 1) but with no luck.

I'm setting the SPI on the microcontrontroller as follows: data transmitted as MSB first, clock low in idle state, data is captured on rising edge, data size is 8 bits, and full duplex transmission.

In main.c I do:

http://e2e.ti.com/support/data_converters/precision_data_converters/f/73/t/3147aspx#

1

2

3

4

5

6

debug = ads7870Init();

if

(debug==1)

printf

(

''adc is alive \n''

);

else

printf

(

''adc is DEAD \n''

);

And in

http://www.ti.com/product/ads7870

_driver.c I have:

http://e2e.ti.com/support/data_converters/precision_data_converters/f/73/t/3147aspx#

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

//initialize ADC

uint8_t ads7870Init(

void

)

{

//// check ID register

if

(ads7870ReadReg(ADS7870_ID) != ADS7870_ID_VALUE)

return

0;

else

{

//// setup reference and buffer

ads7870WriteReg(ADS7870_REFOSC, ADS7870_REFOSC_OSCE | ADS7870_REFOSC_REFE | ADS7870_REFOSC_BUFE);

//// return success

return

1;

}

}

I'm attaching a screenshot of what I see on the scope. (yellow: sclk, blue: read command register 31, purple: output from ADC).

http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/73/67stm32f4_5F00_response_5F00_scope.PNG

MOSI transmits properly to the

http://www.ti.com/product/ADS7870

(the din pin receives read command), but there is no response coming from the ADC dout pin.

I would really appreciate any help on this.

Thank you.

20 REPLIES 20
chen
Associate II
Posted on January 15, 2014 at 10:33

Hi

Are you trying to communicated with the ADC immediately on STM32 boot?

Bear in mind that the STM32 will boot faster than the ADC will be ready (STM32 will start booting as soon as power reaches 1.8V)

What Voltage does the ADC work at?

What reset circuitry is on the STM32?

Posted on January 15, 2014 at 10:52

Don't you find disturbing that your waveform doesn't match the read waveform in the ADS7870 datasheet (Fig.18)?

JW

lowpowermcu
Associate II
Posted on January 15, 2014 at 12:40

Hi,

Can you share your init function (configuration of SPI)?

camila
Associate II
Posted on January 16, 2014 at 13:10

I'm using an evaluation board, so there's no reset circuitry. I'm powering the ADC from VDD on the STM32 discovery, so the power is the same for both. I'm also placing a breakpoint before the initialization of the ADS7870, so there should be enough time for this to boot.

camila
Associate II
Posted on January 16, 2014 at 13:13

It is the same waveform. Data is latched in the rising edge as in the datasheet.

Here is the waveform I obtain when using the ADS7870 with ATMEGA8 (where everything works properly).

0690X00000604yzQAA.png

camila
Associate II
Posted on January 16, 2014 at 13:17

Here is my init function for the SPI:

void spi2_init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Peripheral Clock Enable -------------------------------------------------*/
/* Enable the SPI clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE);
/* SPI GPIO Configuration --------------------------------------------------*/
GPIO_PinAFConfig(SPI2_MISO_MOSI_GPIO, SPI2_MISO_PIN, GPIO_AF_SPI2); //configure MISO pin
GPIO_PinAFConfig(SPI2_NSS_SCK_GPIO, SPI2_SCK_PIN, GPIO_AF_SPI2); //configure SCK pin
GPIO_PinAFConfig(SPI2_MISO_MOSI_GPIO, SPI2_MOSI_PIN, GPIO_AF_SPI2); //configure MOSI pin
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_InitStructure.GPIO_Pin = SPI2_MISO_GPIO_PIN | SPI2_MOSI_GPIO_PIN;
GPIO_Init(SPI2_MISO_MOSI_GPIO, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_InitStructure.GPIO_Pin = SPI2_SCK_GPIO_PIN;
GPIO_Init(SPI2_NSS_SCK_GPIO, &GPIO_InitStructure);
/* SPI configuration -------------------------------------------------------*/
SPI_I2S_DeInit(SPI2);
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; //data captured on falling dge and clk idle is high
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8; //2.625MHz
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
/* Initializes the SPI communication */
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
/* Disable the I2S2 TXE Interrupt */ 
SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_TXE, DISABLE);
/* The Data transfer is performed in the SPI interrupt routine */
/* Enable the SPI peripheral */
SPI_Cmd(SPI2, ENABLE);
SPI_Init(SPI2, &SPI_InitStructure);
}

Thank you all for the help!

chen
Associate II
Posted on January 16, 2014 at 13:40

Hi

''Bear in mind that the STM32 will boot faster than the ADC will be ready (STM32 will start booting as soon as power reaches 1.8V)''

'' I'm also placing a breakpoint before the initialization of the ADS7870, so there should be enough time for this to boot.''

Not a good solution for you final code is it now?!?

Silly question - have you tied the SS (Slave select) from STM32 to  CS on the ADC?

What have you done with the Reset line on the ADC?

What have you done with the OscEnable line?

In fact have you read the data sheet for the ADC?

Pay attention to the section ''REQUIRED SUPPORT ELEMENTS''

Posted on January 16, 2014 at 13:58

>> Don't you find disturbing that your waveform doesn't match the read waveform in the ADS7870 datasheet (Fig.18)?

> It is the same waveform.

No, it is not. The datasheet figure shows the command LSB first, yours is MSB first.

Meantime, reading the datasheet revealed, that it features both, and MSB first is the default. A cunning way to mislead the casual reader...

Also, you don't show the /CS signal. The description in the datasheet indicates, that it's important to have a low-going transition on /CS before start of communication. There is an alternative procedure described on the bottom of page 17.

> Data is latched in the rising edge as in the datasheet.

But that's only if the RISE/FALL pin is tied to 1. How is it in your circuit?

> Here is the waveform I obtain when using the ADS7870 with ATMEGA8 (where everything works properly).

Then what are the differences between these two cases?

JW

Posted on January 16, 2014 at 14:03

One more thing - the waveform you presented above exhibits significant ringing on the edges. If these are real and not only artifacts of improper measurement setup, they may be seen by the SPI receiver in the ADC as false clocks and throw the receiver out of sync.

JW