2020-04-13 10:38 AM
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?
2020-04-13 12:11 PM
What of this code exactly is related to SPL?
JW
2020-04-13 06:39 PM
in using standard library , the ADC reading is ok as bleow fig.
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);
}
first of all, is it Correct using HAL_SPI_Receive(~~~) for reading the ADC?
if no, what do i do to read it?