Skip to content

Instantly share code, notes, and snippets.

@Ryanhu1015
Last active October 22, 2020 16:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ryanhu1015/495eb99a426a62389a4b7d20a371dd8c to your computer and use it in GitHub Desktop.
Save Ryanhu1015/495eb99a426a62389a4b7d20a371dd8c to your computer and use it in GitHub Desktop.
embedded rookie
void txsenddata(short);
char ch;
char chstring[]="Please type something to test: ";
void main(){
for(int i=0; i<sizeof(chstring); i++) txsenddata(chstring[i]);
while(1){
if(enableWrite){
txsenddata(ch);
enableWrite=0;
}
}
}
void txsenddata(short da){
S0BUF=da;
while (TI0==0){}
TI0=0;
}
void UART_ISR(void) interrupt ISRUart {
if (!enableWrite){//let S0BUF just do one job at the same time
RI0=0;
ch = S0BUF;
enableWrite=1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment