Visible to Intel only — GUID: iga1430780163640
Ixiasoft
1.1. Prerequisites for HAL Device Driver Development
1.2. Developing the HAL UART Device Driver
1.3. Debugging the bit_bang_uart Project
1.4. The BitBangUartTransmit() Function
1.5. The BitBangUartReceive() Function
1.6. Creating Device Hardware Access Macros
1.7. Staging the HAL Device Driver Development
1.8. Understanding the Hardware-Specific INSTANCE and INIT Macros
1.9. Integrating a New HAL Device Driver in the BSP
1.10. Understanding HAL Mutual Exclusion Resources
1.11. Overview of Debugging Tools for HAL Device Drivers
1.12. Debugging the HAL UART Device Driver
1.13. Conclusion
1.14. Document Revision History
Visible to Intel only — GUID: iga1430780163640
Ixiasoft
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.
Figure 19. incoming_character Variable Is Set to the Character Entered on the Console