cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L433RB sip external ADC 14bit

hkim.1
Associate

i am trying to work ADS8324/TI with STM32L433RB.

http://www.ti.com/lit/ds/sbas172a/sbas172a.pdf

in using standard library , it is ok as below.

#define ADS8324_DIN P3_3

unsigned short ads8324_ReadData(void)

 register unsigned char i;

 register unsigned char newdata;

 register unsigned short retdata;

 L_CS; 

  for(i=0;i<6;i++)

 {

   H_SCLK; 

   H_SCLK; 

   H_SCLK;  

   H_SCLK; 

   H_SCLK;  

   L_SCLK;

   L_SCLK;

 }

  newdata = 0;

 for(i=0;i<6;i++)  //<=8

 {

  newdata <<= 1;

  H_SCLK; H_SCLK; H_SCLK; /

  newdata |= ADS8324_DIN? 0:1;      

  L_SCLK; L_SCLK; L_SCLK;

 }

 retdata = (newdata+0xE0)&0x3F; retdata <<= 8;

 //data low 8bit

 for(i=0;i<8;i++)

 {

  newdata <<= 1;

  H_SCLK; H_SCLK; H_SCLK; //

  newdata |= ADS8324_DIN? 0:1;      

  L_SCLK; L_SCLK; L_SCLK; 

 }

 retdata |= newdata;

 H_CS;  

 return retdata;

}

but i know STM32L433RB dose not support Standard libary.

if like that, which function of hal libary do i use to read the adc?

also what dose it have to set up on STM32CubeMX for code generation?

2 REPLIES 2

What of this code exactly is related to SPL?

JW

hkim.1
Associate

in using standard library , the ADC reading is ok as bleow fig.

0693W000000VkVRQA0.jpg

in using hal library, the ADC reading is not good as bleow fig.

uint16_t Sample;

uint8_t high, low;

uint8_t readByte;

void read_ADS8324(void)

{

pADS8324_CSL;

HAL_SPI_Receive(&hspi2,&readByte,1,5000);

high=readByte;

HAL_SPI_Receive(&hspi2,&readByte,1,5000);

low=readByte;

pADS8324_CSH;

printf("Sample: %x %x\r\n",high,low);

}

0693W000000VkVqQAK.jpg

first of all, is it Correct using HAL_SPI_Receive(~~~) for reading the ADC?

if no, what do i do to read it?