Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 fosc = 20.000000 void UART_Init(void) { RC1STAbits.SPEN = 0; // begin of setup disable serial port. // transmitter TX1STAbits.TXEN = 1; // continues transmit enable bit TX1STAbits.TX9 = 0; // 8 bit transmission TX1STAbits.SYNC = 0; // asynchronous operation ANSELCbits.ANSC6 = 0; // digital TRISCbits.TRISC6 = 0; // output // receiver RC1STAbits.CREN = 1; // continues receive enable bit RC1STAbits.RX9 = 0; // there is only one sync ANSELCbits.ANSC7 = 0; // digital TRISCbits.TRISC7 = 1; // input // baudrate. TX1STAbits.BRGH = 1; BAUD1CONbits.BRG16 = 1; SPBRG = 520; // baudrate 9600 RC1STAbits.SPEN = 1; // end of setup enable serial port } void UART_TxChar(uchar ch) { while(TXIF==0); TXREG=ch; } uchar UART_RxChar() { uchar Discard; while(1){ while(RCIF==0); // Wait till the data is received if (RCSTAbits.FERR) { Discard = RCREG; Read the register and wait for the next byte break; } if (RCSTAbits.OERR) { RCSTAbits.CREN = 0; break; } return RCREG; // Return the received data } }
Show how you tested it. --> what did you expect?
Show the test results.--> what happened instead?