cancel
Showing results for 
Search instead for 
Did you mean: 

I am interfacing ADS8688 with stm32f429zi, I have used SPI. I have 2 different setup. first setup with 3 ADC in which all ADC channels gives output near 47000 and Second setup with 8 ADC which channels gives values near 23000. Why it gives half values?

AH_nt
Associate II
 
4 REPLIES 4

Data shifted by one but for some reason? Observe SPI bus using logic analyzer and compare to waveform given in the ADC datasheet.

If SCK pin's GPIO OSPEEDR setting is low, try increasing it to medium.

JW

Thank you reply.. I checked SCK pin, it is high only. I will add here that I am using SPI with DMA here.

This is my SCK GPIO configuration.

/*##-2- Configure peripheral GPIO ##########################################*/ 

   /* SPI SCK GPIO pin configuration */

   GPIO_InitStruct.Pin      = SPI4_SCK_PIN;

   GPIO_InitStruct.Mode     = GPIO_MODE_AF_PP;

   GPIO_InitStruct.Pull     = GPIO_PULLUP;

   GPIO_InitStruct.Speed    = GPIO_SPEED_HIGH;

   GPIO_InitStruct.Alternate = SPI4_SCK_AF;

   HAL_GPIO_Init(SPI4_SCK_GPIO_PORT, &GPIO_InitStruct);

1.Register_write finction.

2.ADC_Read finction.

uint8_t ADC_ADS8688_2_Register_Write(uint8_t RegAddrVal, uint8_t Data)

{

 uint8_t TempTx[3] = {0,0,0}, TempRx[3] = {0,0,0};

 HAL_GPIO_WritePin(SPI4_ADC_ADS8688_2_CS_GPIO_PORT, SPI4_ADC_ADS8688_2_CS_PIN, GPIO_PIN_RESET); 

 TempTx[0] = (RegAddrVal << 1) | 0x01;

 TempTx[1] = Data;

 TempTx[2] = 0x00;

 if(HAL_SPI_TransmitReceive_DMA(&Spi4Handle, TempTx, TempRx, sizeof(TempTx)) != HAL_OK)

 {

   /* Transfer error in transmission process */

   Error_Handler();

 }   

 while(Spi4Handle.State != HAL_SPI_STATE_READY);

 HAL_GPIO_WritePin(SPI4_ADC_ADS8688_2_CS_GPIO_PORT, SPI4_ADC_ADS8688_2_CS_PIN, GPIO_PIN_SET);

 if(TempTx[1] == TempRx[2])

 {

  return 1;

 }

 else

 {

  return 0;

 } 

}

void ADC_ADS8688_2_Read_Channel(uint8_t *data)

{

 uint8_t TempTx[4] = {0,0,0,0}, TempRx[4] = {0,0,0,0};

 memset(TempTx, 0x00, sizeof(TempTx));

 memset(TempRx, 0x00, sizeof(TempRx));

 HAL_GPIO_WritePin(SPI4_ADC_ADS8688_2_CS_GPIO_PORT, SPI4_ADC_ADS8688_2_CS_PIN, GPIO_PIN_RESET); 

 if(HAL_SPI_TransmitReceive_DMA(&Spi4Handle, TempTx, TempRx, sizeof(TempTx)) != HAL_OK)

 {

   /* Transfer error in transmission process */

   Error_Handler();

 }   

 while(Spi4Handle.State != HAL_SPI_STATE_READY);

 HAL_GPIO_WritePin(SPI4_ADC_ADS8688_2_CS_GPIO_PORT, SPI4_ADC_ADS8688_2_CS_PIN, GPIO_PIN_SET); 

 memcpy(data, &TempRx[2], 2); 

}