Last active
October 22, 2020 16:35
-
-
Save Ryanhu1015/495eb99a426a62389a4b7d20a371dd8c to your computer and use it in GitHub Desktop.
embedded rookie
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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