Guidelines for Developing a Nios II HAL Device Driver

ID 683146
Date 6/12/2015
Public
Document Table of Contents

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:

  1. Step into the BitBangUartReceive() function.
  2. 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.
  3. Click the Resume button.
    Figure 17. Setting a Breakpoint in BitBangUartReceive()
  4. 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
  5. In the Tera Term, type * (asterisk). The debugger hits the breakpoint you set, as shown in the figure below.
  6. 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.

Figure 19. incoming_character Variable Is Set to the Character Entered on the Console

Did you find the information on this page useful?

Characters remaining:

Feedback Message