Guidelines for Developing a Nios II HAL Device Driver

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

1.12.1. Setting Breakpoints in the my_uart_driver Device Driver

This section demonstrates the use of breakpoints to examine HAL device driver activity. Perform the following steps:

  1. After importing the hello_world_my_uart project, open the my_uart_init.c device driver source file, located in the hal_my_uart project, at the following directory:

    <my_design> /software_examples/bsp/hal_my_uart/drivers/src/my_uart_init.c

  2. Place a breakpoint at the top of the function named my_uart_irq(), as shown in the figure below.
  3. Restart Tera Term if it is not already running.
  4. Create a debug configuration for hello_world_my_uart by following the steps 3 through 8 in Debugging the bit_bang_uart Project and substituting the hello_world_my_uart application for the bit_bang_uart application.
  5. Start debugging the hello_world_my_uart application. The processor pauses at the top of function main().
  6. Click the Resume button. The Nios II processor pauses at the my_uart_irq() invocation.
    Figure 20. Setting a Breakpoint on my_uart_irq()
  7. Step up to and over the following assignment of the status register:

    status = IORD_MY_UART_STATUS(base);

  8. In the Variables view, set the format of the status variable to hex. The status register now holds the value 0x60. This value indicates bits 5 and 6 are set. According to the my_uart_driver register description in drivers/inc/my_uart_regs.h, these two bits indicate transmit ready and transmit. The UART driver is in an interrupt context, ready to transmit the first character of the string "Hello from Nios II!".
  9. Continue stepping through the procedure. The my_uart_irq() function invokes my_uart_txirq() in response to a transmit interrupt.

    Press Resume after each character is transmitted. Stop after the entire string “Hello from Nios II!” is transmitted.

  10. Remove the breakpoint.

After you pause the debugger in an ISR, the rest of the system is in an unknown state, because it could not respond to other interrupt requests while paused in the driver. Therefore, you need to start a new debugging session to perform further debugging.