英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流
标题:
简单十进制到BCD程序
[打印本页]
作者:
winnie
时间:
2009-3-21 18:02
标题:
简单十进制到BCD程序
unsigned char DspData[4];
unsigned int Sum,temp;
void IntToBcd()
{
DspData[0]=(unsigned char)(Sum%10);
Sum=Sum/10;
DspData[1]=(unsigned char)(Sum%10);
Sum=Sum/10;
DspData[2]=(unsigned char)(Sum%10);
Sum=Sum/10;
DspData[3]=(unsigned char)(Sum%10);
/*DspData[0]=(unsigned char)(Sum/1000);
Sum=Sum-DspData[0]*1000;
DspData[1]=(unsigned char)(Sum/100);
Sum=Sum-DspData[1]*100;
DspData[2]=(unsigned char)(Sum/10);
DspData[3]=Sum-DspData[2]*10;*/
}
void main()
{
Sum=4567;
IntToBcd();
Sum=(int)DspData[0];
}
欢迎光临 英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流 (http://enroobbs.com/)
Powered by Discuz! X3.2