Any better way to detect Signal with ADC Overflow problem?
How do you transform overflowed signal back to normal? Just by adding or subtracting multiplies of 256. So with every new sample you just determine whether overflow occured - you need to define some threshold and compare it with first derivative of your signal, e.g. x[i+1]-x[i] &gt; 200. If this happened, you know that you need to subtract 256 from x[i+1] to get continuous signal. Opposite case x[i+1]-x[1] &lt; -200 means that you need to add 256. So the pseudocode would be:

base = 0
thresh = 200
for each i in x
  d = x[i] - x[i-1]
  if d &gt; thresh then base = base - 256
  if d &lt; -thresh then base = base + 256
  y[i] = x[i] + base
next