www.pudn.com > DDS485.rar > datachange.c
#include#include #include #include //-----***-16近制数据转化为BCD-***-----// unsigned char HexToBcd(unsigned char Bytedata) { unsigned char ii,Byte; /*定义减数i,被减数j,相减蚀锡k,余数h*/ ii=0; while(Bytedata>=0x0a) { Bytedata=Bytedata-0x0a; ii=ii+1; } Byte=16*ii+Bytedata; return Byte; } //-----***-BCD数据转化为16近制-***-----// unsigned char BcdToHex(unsigned char Bytedata) { unsigned char i,j,Byte; /*定义减数i,被减数j,相减蚀锡k,余数h*/ i=Bytedata & 0xf0; j=Bytedata & 0x0f; Byte=10*(i>>4)+j; return Byte; } //-----***-接受的数据减去0x33-***-----// void DataDeal(void) { unsigned char i; for(i=10;i