我用得芯片是9S08RG60 我用串口发送数据 采用串口调试助手接受 查看。
byte Fare[15]={0x00,0x00,0xFF,0x07,0xF9,0x30,0x00,0x04,0x27,0x10,0x00,0x00,0x95,0x00,0x00}; byte *R_pbuffer;
void SCI1_write(byte *point, int num) { byte *p=point; byte i=0; SCI1C2_TE=1; while(i<num) { while(!SCI1S1_TDRE); /* ensure Tx data buffer empty */ SCI1DRL=*p++; /* load data to data register */ i++; while(!SCI1S1_TC); /* wait for Tx complete */ } SCI1C2_TE=0; }
void main(void) {
flag=0; count=0; EnableInterrupts; /* enable interrupts */ /**busclock=external clock(16M)/2=8M*/ SCI1BDH=0X00; SCI1BDL=0X34; SCI1C2_TE=1; //ena Transmit SCI1C2_RE=1; //ena Receive SCI1C2_RIE=0; //dis Receive interrupt SCI1_write(Fare,15);
for(;;) { __RESET_WATCHDOG(); /* feeds the dog */ } }
我得程序每次都比我要发得数据多一个 有时候还多两个。
分别在EnableInterrupts; 时显示发送了一个数据0x00
然后在SCI1_write(byte *point, int num)函数SCI1C2_TE=0; 运行完后又发送了一个数据。 不知道为什么。
|