似乎柏树科技的支持已经不复存在了。哦,天哪!
这是我的问题:我的小程序,将一个二进制数字转换为ASCII字符串,并返回字符串的字符数。它包括领先的消零如果需要(cfixeddigitcount = 0)或固定长度的消息带前导零。看起来像这样。
cbinarytoascii uint8(uint16 ISOURCE,uint8 sconversion [],uint8 cfixeddigitcount)
{//返回字符串中的字符数
/cFixDeDigigt允许前导零
u
tiN C点,CI;
uTIN 16;
C点=0;
当(伊索)!= 0)
{
IRMAMEDER = ISURCE % 10;
转换[cPosi]=(uTIn8)(iReMeNead)0x30;
C点++;
iSouCE=10;
}
如果(cFixDigDigig计数)
{//仅当非零时,否则引导零闪烁
如果(C点& lt;(cFixDigDigig计数))
{
对于(CI=0;CI & lt;(CcIdDigDigigalCcPoT);Ci++)
{
sconversion [ CPoint ] = '0';
CPoint + +;
}
}
}
返回CPoint;
}
到目前为止,它似乎已经奏效了。该计划自我测试了它长大了不少,但我还没有看到的问题。
我只是用它在一个新的模块如下
CJ = cbinarytoascii(iretrievedparameter,casciiresult,0);
CJ是一个地方的卡片,casciiresult是uint8阵列5
当我走过cbinarytoascii,或通过它与断点,出现CPoint的号码是正确的,在这种特定的情况下。但在调用模块CJ值0x1a。如果我改变CJ从局部变量的一个全球性的,它的正确性。
不知道我做错了什么,或是在编译错误?
编译器的细节
PSoC Creator(4.2.0.641 4.2)
以上来自于百度翻译
以下为原文
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;
cPoint=0;
while (iSource!=0)
{
iRemainder=iSource%10;
sConversion[cPoint]=(uint8)(iRemainder) | 0x30;
cPoint++;
iSource/=10;
}
if (cFixedDigitCount)
{//only if non-zero, else leading zero blnking
if (cPoint<(cFixedDigitCount))
{
for (cI=0;cI<(cFixedDigitCount-cPoint);cI++)
{
sConversion[cPoint]='0';
cPoint++;
}
}
}
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=cBinaryToAscii(iRetrievedParameter,cASCIIResult,0);
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 (4.2.0.641)