1.5. The BitBangUartReceive() Function
This section examines the BitBangUartReceive() function in bit_bang_uart.c. The BitBangUartReceive() function demonstrates receiving characters over the UART.
To analyze the BitBangUartReceive() function, perform the following steps:
- Step into the BitBangUartReceive() function.
- Set a breakpoint on the while loop immediately after the statement that reads a character into incoming_character, as shown in the Setting a Breakpoint in BitBangUartReceive() figure below.
- Click the Resume button.
Figure 17. Setting a Breakpoint in BitBangUartReceive()
- In the following loop statement, the Nios II processor is waiting for the receive ready (RRDY) bit to go high:
while (!(uart_status=IORD(UART1_BASE, 2) & 0x80));
Tera Term displays a prompt, as shown in the figure below.Figure 18. Waiting to Receive Character on UART
- In the Tera Term, type * (asterisk). The debugger hits the breakpoint you set, as shown in the figure below.
- Examine the Variables view (expand it if necessary to see the incoming_character variable). The incoming_character variable holds the asterisk you sent through Tera Term, as shown in the figure below.
Completing these steps verifies that both the transmit and receive functions of the UART work in polled mode.
Did you find the information on this page useful?