In this method, the supplied characters of printf are redirected to user defined medium as defined by void stdout_putchar (int ch) function. User defined Medium- printf-to-UART/USART:
Redirecting printf to STlink Debugger on STM32F4-Discovery using Keilįor illustration purpose we will direct printf messages to USART-3 of STM32F4-Discovery board. printf redirection to Stlink Debugger is described in the following tutorial. printf redirection to user defined Medium. In this tutorial we will focus on first method i.e. None, Just stop processor to analyze system state. STLINK Debugger via ARM Instrumentation Trace Macrocell (ITM). User defined Medium like UART, SPI, CAN etc. Keil provides Run-Time libraries to direct printf messages to: In such systems “Blinky Led” is the best alternative and most commonly used debug assistant BUT if printf is affordable on embedded board, it can provide much better assistance than “Blinky Led”.Īnyhow irrespective of printf pros and coins, we will discuss how it can be used on STM32F4-Discovery Microcontroller/kit platform using Keil. Which indeed is a problem on memory space limited and relatively slower speed embedded systems. In embedded systems, the printf is not used frequently due to: The “C” printf is one of the most commonly used debug function/assistant used in DESKTOP applications. Fault mask register (FAULTMASK) is used to disable all interrupts excluding non-maskable interrupts (NMI).Embedded systems, ARM, STM32F4, UART, ITM, printf Control register (CONTROL) sets the choice of main stack or process stack, and the choice of privileged or unprivileged mode. If an interrupt is masked, this interrupt is ignored (i.e. Priority mask register (PRIMASK) is used to disable all interrupts excluding hard faults and non-maskable interrupts (NMI). xpsr (Special-purpose program status registers) is a combination of the following three processor status registers: Application PSR Interrupt PSR Execution PSR N Negative or less than flag (1 = result negative) Z Zero flag (1 = result 0) C Carry or borrow flag (1 = Carry true or borrow false) V Overflow flag (1 = overflow) Q Q Sticky saturation flag T Thumb state bit IT If-Then bits ISR ISR Number ( 6 bits ) System: Base priority mask register (BASEPRI) defines the minimum priority for exception processing. Stack point (SP) r13 holds a memory address that points to the top of the stack. 1Ĥ Processor Registers Core Registers: Program counter (PC) r15 holds the memory address (location in memory) of the next instruction to be fetched from the instruction memory. Step In: Execute one step and enter the function if the current step calls a function. Start Debug Set a Breakpoint Run Stop Debug Step In Step Over Step Out Run: Continues the execution from the current position until you click Stop or the program is paused by a breakpoint. The following table summarizes commonly used debug control buttons. If the source window is focused, the debugger then steps through the source lines instead. If the disassembly window is in focus, the debugger executes assembly instructions step by step. When a program stops at a breakpoint, the corresponding instruction has not been executed yet. STM32 allows up to six breakpoints during hardware debugging.
You can use the breakpoint button to set a break point in either disassembly or source windows. Click the debug button to start the debug and click it again to exit the debug.
Keil 5 debug stm32f4 software#
Selecting software debug Selecting hardware debug Debug Control You can program the STM32 flash by clicking the LOAD button. However, the hardware debug requires you to connect the board to the computer. By using the software debug, you do not have to have the hardware board to debug a software program. 1 Keil Debugger Tutorial Yifeng Zhu DecemSoftware vs Hardware Debug There are two methods to debug your program: software debug and hardware debug.