title: Casting integer to uint8_t
body: <p>I am trying to write a small function that calculates difference for each pixel. However, seems like casting int to uint8_t ( (uint8_t)temp ) is causing problems on a microprocessor at the very first iteration and leads to a restart</p>
  <hr />
  <pre><code>abs_diff = (uint8_t*)malloc(320*240 * sizeof(uint8_t));
  
  for (int i = 0; i &lt; 320*240; i++){
      int temp = abs((int)_jpg_buf[i] - (int)_jpg_buf_prev[i]);
      Serial.printf(&quot;abs %d\n&quot;, temp);
      abs_diff[i] = (uint8_t)temp; // &lt;- fails
  }
  </code></pre>
  <p>P.S. not a C expert here</p>