9 Replies Latest reply on Dec 1, 2015 6:23 AM by user_1377889

    PSoC 5LP Digital Filter block 2 complement

    daniel.caliari

      Hi Everybody,

         

      Why does the Digital Filter block works in 2 complements If the filter does not deal with negative values?

         

      In the examples they write the following code line:

         

          /* Convert the 2's complement value to an unsigned 8-bit value
           * The VDAC expects an unsigned 8-bit value as input.
           */

         

      VDAC8_SetValue(Filter_Read8(Filter_CHANNEL_A) + 128u);

         

       

         

      What mechanism of conversion is that? Since I know digital electronic I've never heard about converting 2 complements in this way. For me, the binary should be inverted ( the 0s become 1s and the 1s become 0s) and then summed by 1.

         

      How can I convert a non 2 complement's number to a 2 complement's number in PSoC 5LP?