Something about your max and min routine doesn't look right. On the first iteration you should compare max against a value greater than, or equal to, half of full-scale and compare min against a value less than, or equal to, half of full-scale. Since this is an un-signed ten-bit integer from the...