Depuração JTAG com LPC1768- (Parte 3/21)

JTAG debugging with LPC1768- (Part 3/21)

The process of resolving bugs or defects that interfere with the proper functioning of a computer software or operating system is known as Debugging. This article covers the configuration and use of a JTAG debugger with an ARM Cortex M3 microcontroller. To configure the ARM cortex M3 development environment, see this article.

The LPC 1768 is an ARM Cortex-M3-based microcontroller for embedded application capabilities with low power consumption and a high level of integration. The ARM Cortex M3 is designed in a way to enhance debugging capabilities and a higher level of system integration. It runs at a CPU frequency of 100 MHz and incorporates a 3-stage pipeline and uses a Harvard architecture with separate local instruction and data buses for third-bus peripherals. The ARM Cortex-M3 CPU has an internal prefetch unit to support speculative branches. Peripheral components include 512 KB flash memory, 64 KB data memory, Ethernet MAC, USB OTG, 4 UARTs, 8-channel general-purpose DMA controller, 2 SSP controllers, 10-bit DAC, quadrature encoder interface, SPI interface, 3 bus I2C interface, 2-input plus 2-output I2S bus interface, 4 general-purpose timers, ultra-low power real-time clock (RTC) with separate battery supply, and up to 70 user I/O pins General, 6-output general-purpose PWM. The LPC1768/66/65/64 are pin compatible with the 100-pin LPC236x ARM7 based series of microcontrollers.

The following components are used in this tutorial:

  1. Debugger – Your choice

  2. Controller/board – LPC1768/Explore Cortex M3

  3. IDE/Compiler – Keil

As you know, JTAG can be used to program and debug the controller. The main use of JTAG is when you need to work on a huge list of codes. It can be used to add step and break points throughout the code. The image below shows the pin diagram of the Explore ARM Cortex M3 (LPC1768). It has a 20-pin JTAG ARM connector.

Connecting the hardware:

Diagrama de pinos do Explore ARM Cortex M3 LPC1768

Fig. 1: Explore ARM Cortex M3 LPC1768 pin diagram

It should be noted that connecting the debugger to the board will not power it on. An external power adapter needs to be connected to the board. Once the hardware is configured, we can move on to the software part.

Selecting the debugger

  • Click on the Projects tab and then on “Target Options” (ATL + F7)

  • Click on the “Debug” tab

  • The default selection is “Simulator”. Change the selection to “Name of your debugger”.

  • Click “OK” to proceed

Selecionando o depurador

Fig. 2: Selecting the debugger

Debug options for NXP LPC1768:

Now select the Debug tab. In the right pane of the current window, you will find an option button called “Use”. From the drop-down list, select the name of the debugger you are using.

Opções de depuração para NXP LPC1768

Fig. 3: Debug options for NXP LPC1768

Utilities option for the NXP LPC1768:

Click on the “Utilities” tab and you will see a window as shown below.

Opção de utilitários para o NXP LPC1768

Fig. 4: Utilities option for the NXP LPC1768

Select the same debugger chosen in the previous window. The “Settings” button in this window will show the same options as the Debug window. It is highly recommended that the Debug and Utilities options are configured before proceeding to “Settings”.

Debug/Utility Settings Using NXP LPC1768:

Click the “Settings” key and confirm the Debug tab to get the window as shown below.

Configurações de depuração/utilitários usando o NXP LPC1768

Fig. 5: Debug/Utility Settings Using NXP LPC1768

Grades:

  • The settings in the “Debugging” and “Utilities” tabs need to be configured before confirming the settings.

  • The link and destination must be present to see these options.

  • The “Stop after Bootloader” option must be chosen.

Flash download options for the NXP LPC1768:

In the “Flash Download” tab, confirm the options as shown below. If desired, select the “Reset and run” checkbox.

Opções de download de Flash para NXP LPC1768

Fig. 6: Flash download options for the NXP LPC1768

If the space under “Programming Algorithm” is blank, select “ADD” and select a name from the list displayed below.

Debug programs:

Invoke the debugger

  1. Click the Magnifier in the toolbar.

Debug enable/disable icon

  1. If the MDK “EVALUATION” mode is being used, the message shown below will appear. Click “OK”.

Caixa de diálogo Modo de avaliação

Fig. 7: Evaluation mode dialog box

Message with MDK evaluation

3.The Debugger will perform the following steps:

. Turn off the flash

. Download the code

. Reset the microcontroller and execute the address Reset_Handler or “main” depending on the options that were defined in the configuration. A possible window log will be shown below:

Log de comando ao invocar o depurador

Fig. 8: Command log when invoking the debugger

Command log when invoking debugger

4.Then the debug screen will appear.

Debugger run options

Fig. 10: Debugger execution options

Debugger run options

There are 7 execution options:

  1. Reset microcontroller

  2. Run the microcontroller normally

  3. Stop debugging

  4. Single step, one instruction at a time

  5. Skip functions

  6. Exit functions

  7. Run to the cursor

A typical debugging session might consist of the following steps:

  1. Enter Debug mode – the debugger will run at address Reset_Handler (or “main” if selected in configuration)

  2. Click the cursor on a line of source code to start the investigation

  3. Click on the 7th option to run the program at the cursor. All registry changes will be highlighted.

  4. Click the Center icon to run the code in one step as needed.

  5. If the single step enters a loop, use the 6th key to exit this function.

  6. If further investigation is not necessary, use the second key to run at full speed.

  7. To stop, use the 3rd key.

  8. To restart the entire sequence, use the first key

  9. To exit the debug session, select the magnifying glass which is present on the main toolbar.

Breakpoints

Fig. 11: Breakpoint icons

There are 4 breakpoint icons:

  1. Place a breakpoint at the current cursor position. This will be shown as a red dot.

  2. A running program will stop at the breakpoint

  3. If the breakpoint is in a loop restarting the program, it will stop at the breakpoint on the next pass.

  4. Toggle: Disable/re-enable a breakpoint on the cursor. Disabled breakpoints will be represented as an open circle.

  5. Disable all breakpoints: they will be represented as open circles. They can be reactivated individually.

  6. Delete all breakpoints: All breakpoint positions will be removed.

Observation window

Various windows can be activated or deactivated using toolbar icons.

Fig. 12: Options for debugger in Windows

Windows display options for the debugger

The windows that can be enabled or disabled are:

  1. Command window. (Shown by default)

  2. Disassembly window. (Shown by default)

  3. Symbols window (hidden by default)

  4. Registration window (displayed by default)

  5. Call stack window (displayed by default)

  6. Observation windows (hidden by default)

  7. Memory windows (shown by default)

Grades:

  • When Call Stack, Memory, and Observation are enabled, they will appear in the bottom right pane.

  • When selected, the symbols window will appear as shown below:

Janela de símbolos

Fig. 13: Symbols Window

Circuit diagrams

JTAG-Debug-With-LPC1768

Related Content

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.