unsigned char dtoa(char c1){
return (c1>=10)? (c1+0x37):(c1+0x30);
}
说这句...程序在这里...我刚学,大哥们教教我啊,
#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
/* put your own code here */
void SCI_init(void);
void SCISendChar(char c1);
void SCISendString(char *pc1);
void SCISendHex(char c1);
unsigned char dtoa(char c1);
void ATD_init(void);
void main(void){
SCISendString("wo shi ben dan");
EnableInterrupts;
for(;;) {
_FEED_COP(); /* feeds the dog */
} /* loop forever */
/* please make sure that you never leave main */
}
void SCI_init() {
SCI0BDH=0;
SCI0BDL=52;
SCI0CR2=0x0c;
}
void SCISendChar(char c1){
while(SCI0SR1_TC==0);
SCI0DRL=c1;
}
void SCISendString(char *pc1){
while((*pc1)!=0){
SCISendChar(*pc1);
pc1++;
}
}
void SCISendHex(char c1){
SCISendChar(dtoa((c1&0xf0)>>4));
SCISendChar(dtoa((c1&0x0f)));
}
unsigned char dtoa(char c1){
return (c1>=10)? (c1+0x37):(c1+0x30);
} |