查看: 1181|回复: 3
|
MPlab Soruce Code Help!!
[复制链接]
|
|
要怎样写以下的code?
A=256*B+C
D=A*0.4882125
pic data sheet 里只有ADD,
那乘要用什么?
还有0.488要怎样表达?
hex,dec,bin都不能有0.xxx de |
|
|
|
|
|
|
|
发表于 28-11-2006 08:15 AM
|
显示全部楼层
|
|
|
|
|
|
|
楼主 |
发表于 29-11-2006 10:24 PM
|
显示全部楼层
不懂它的意识,我用pic16f873,
他给的只有16cXXX
A=256*B+C
For this u hav to write a sub routine for multiplication. This can be done using successive addition. If ur value 256 is fixed then u need not want to multiply it. Simply put two zeros in right side.
For example: if B=0x23, then 256*B will be 0x2300, that is two zeroes in right side. Then add C with ur answer. if C=0x45, U will get A=0x2345.
D=A*0.4882125
Remove Decimal point and take the hex value, Multiply it and convert back to decimal and then put the decimal.
Example: In ur equation 0.4882125 , after removing the point u get 4882125, take hex manually, 4882125=0x4A7ECD
change ur equation as
D=A*0x4A7ECD
Then multiply u get 0xA436A3441
Convert it into decimal, u get 44080706625
Then put the decimal point 7 places from right , then u get 44080.706625 ..
以上的能用ma? |
|
|
|
|
|
|
|
发表于 1-12-2006 08:50 AM
|
显示全部楼层
--不懂它的意识,我用pic16f873,
--他给的只有16cXXX
##一样的。
--A=256*B+C
--For this u hav to write a sub routine for multiplication. --This can be done using successive addition. If ur value --256 is fixed then u need not want to multiply it. Simply --put two zeros in right side.
--For example: if B=0x23, then 256*B will be 0x2300, that --is two zeroes in right side. Then add C with ur answer. --if C=0x45, U will get A=0x2345.
##如果, 256 是 constant, B & C 是 integer 就可以这么做
--D=A*0.4882125
##这个就有问题, 要用 fix point multiplication & division:
D = (A * 4882125)/10000000 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|