简单十进制到BCD程序
unsigned char DspData;unsigned int Sum,temp;
void IntToBcd()
{
DspData=(unsigned char)(Sum%10);
Sum=Sum/10;
DspData=(unsigned char)(Sum%10);
Sum=Sum/10;
DspData=(unsigned char)(Sum%10);
Sum=Sum/10;
DspData=(unsigned char)(Sum%10);
/*DspData=(unsigned char)(Sum/1000);
Sum=Sum-DspData*1000;
DspData=(unsigned char)(Sum/100);
Sum=Sum-DspData*100;
DspData=(unsigned char)(Sum/10);
DspData=Sum-DspData*10;*/
}
void main()
{
Sum=4567;
IntToBcd();
Sum=(int)DspData;
}
页:
[1]