Tool/software: Code Composer Studio
hello everyone
I am trying to understand water meter code but i can not understand some parts in TSM_Auto_cal function. Why did they check is math_temp bigger than 12?
do
{
FindDAC(); // using 12 bit sucessive approx. method
DAC0_sum2 = ESIDAC1R0;
DAC1_sum2 = ESIDAC1R2;
DAC2_sum2 = ESIDAC1R4;
// channel 0
if(!(Cal_status&Ch0_finish))
{
if (DAC0_sum2 > LC_Threshold_TSM_CAL)
{
if (DAC0_sum2 > DAC0_sum1)
{math_temp = DAC0_sum2 - DAC0_sum1;}
else
{math_temp = DAC0_sum1 - DAC0_sum2;}
Ch0_counter += 1;
if (math_temp > 12)
{
if (Ch0_counter > cycle_width)
{
for (i= 0; i< Ch0_counter / 2 ; i++)
{ ESITSM3 -= 0x0800; }
Cal_status |= Ch0_finish;
}
else
{Ch0_counter = 0;
DAC0_sum1 = DAC0_sum2;
}
}
else
{
DAC0_sum1 = DAC0_sum2;
}
}