Hello E2E Experts,
Good day.
I am using ADS1232 for my weighing application. The ADC Output is not as per the input. Can you assist me?
AVDD = 5 V, VREF = 5 V, Data Rate = 10 SPS
Below is my code.
unsigned long ADS1232_read()
{
signed long adc_val = 0;
char cy_count = 0;
while(HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_13));
HAL_Delay(4);
for(cy_count = 0; cy_count < 24; cy_count++)
{
adc_val = adc_val << 1;
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET); //clk high
HAL_Delay(4); // min 100ns
if(HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_13)) //data low /high
{
adc_val += 1;
}
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET); //clk low
HAL_Delay(4);
}
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET);
HAL_Delay(2);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13, GPIO_PIN_SET);
HAL_Delay(2);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET);
HAL_Delay(2);
adc_val &= 0x7fffc0;
adc_val = adc_val >>6;
return adc_val;
}
The output code is not accurate as per the input weight.