Hi all . In one way ,all the messages is following a standard format ,like:"SOH,MSG ID, CMPL ID,MSG DATA LENGTH, MSG DATA ,CHECKSUM",so this format can be embed in UART_ISR to receive the message wanted.But,if have some different kinds of message which following different formats ,or baudrate is too high to process in the UART_ISR,how can the firmware process these message?Where have any referenced source code ? Thanks for help.
I rewrite the source code as following:
//Serial ISR: void serial0(void) interrupt 4 { ES0 = 0; if (TI0) TI0 =0; if (RI0) { r_buf[r_in&0x7ff]=SBUF0; RI0 = 0; r_in=r_in+1; } ES0 = 1; } //Main_Loop: void main() { ... while(1) { if ((r_in-r_out)>128) { serial0Flag = 1; } if(serial0Flag==1) { if (r_buf[r_out&0x7ff] =='$') { memcpy(sHeadFlag,&r_buf[(r_out+1)&0x7ff],5); if (memcmp(sHeadFlag,sGpgs[0],5)==0) { GpgsvSol(&r_buf[r_out&0x7ff]); } if (memcmp(sHeadFlag,sGpgs[1],5)==0) { GpgsaSol(&r_buf[r_out&0x7ff]); atelliteLocked=Gpgsa.cSatInSolTol; } } r_out++; } } }