Question 3: (5 points) 25% (CLO1: 20% CLO2: 80%)
a) Using the given code for testing the UART, write a C code that sends a string of data bytes. The data to be sent is the 16-bit number read as input from port B. A 2-second delay is to be introduced between each data entry to port B.
b) Using the given code for testing the UART, write a C code that receives the message sent in part a and stores the data in the 16-bit array uint16 au16_a[100].
int main(void) {
main(void) {
T2CON = 0x0030;
PR2 = 39061;
TRISB5 = 0;
T2IF = 0;
T2CONbits.TON = 1;
while (1) {
if (T2IF == 1) {
T2IF = 0;
LATB5 = _LATB5;
}
}
}
int8 b;
config_UART1_polling(19200);
while (1) {
if (U1STAbits.URXDA) {
b = U1RXREG;
while (U1STAbits.UTXBF == 1) {
U1TXREG = !b;
}
// Other program code that can be executed (non-blocked)
}
}
}