4 Replies Latest reply on Jul 18, 2018 12:42 PM by AuKa_264411

    Bug in return from procedure PSoC5


      It seems that Cypress Tech Support is no more. Oh dear!

      Here is my problem: I have small procedure that converts a binary number to an ASCII string, and returns the number of characters in that string. It includes leading zero blanking if desired (cFixedDigitCount=0) or a fixed length message with leading zeros. It looks like this.


      uint8 cBinaryToAscii (uint16 iSource, uint8 sConversion[], uint8 cFixedDigitCount)

      {//return the number of characters in the string

      //cFixedDigitCount to allow for leading zero  

          uint8 cPoint,cI;

          uint16 iRemainder;


          while (iSource!=0)



              sConversion[cPoint]=(uint8)(iRemainder) | 0x30;




          if (cFixedDigitCount)

          {//only if non-zero, else leading zero blnking

              if (cPoint<(cFixedDigitCount))


                  for (cI=0;cI<(cFixedDigitCount-cPoint);cI++)







          return cPoint;



      Up till now it seems to have worked. The program has grown a lot since I tested it out, but I have not seen problems.


      I have just used it in a new module as follows


      cJ is a local uint8, cASCIIResult is a 5 uint8 array


      When I step through the cBinaryToASCII, or run through it with a breakpoint, the number appearing for cPoint is correct, 4 in this specific case. But in the calling module cJ has a value of 0x1A. If I change cJ from a local variable to a global one, it works correctly.


      Any idea what I am doing wrong, or is there a bug in the compiler?

      Compiler details

      PSoC Creator 4.2 (