67%(3)2 out of 3 people found this document helpful
This preview shows page 7 - 9 out of 14 pages.
f) Logic Analyzer The Logic analyzer in debug mode allows you to visualize a logic trace for a variable during its execution. Thus we could use this as a visualization for the variables we place in the watch window. For this lab, we will graphically follow the ADC_Dbg value in our code: 1.Press the arrow on the icon, and select Logic analyzer. A window will appear (if not already present). 2.In the blinky.c code, right-click on the variable ADC_Dbg. A pop-up menu will appear. Select "Add ADC_Dbgto..." >> Logic Analyzer. The variable will appear in the Logic analyzer window. 3.If you click run, you will see the ADC_Dbg trace generate as a straight line on the zero mark. It should correspond to the value you are seeing in the Watch 1 window. 4.Under the Zoom heading in the Logic analyzer, click "All". This will scale your window according to the execution trace time (horizontally). 5.Under the Min/Max heading, select "Auto" to scale the trace's amplitude (vertically). This ADC_Dbg value will keep running with a zero value. Why? The ADC_Dbg is representative of the value which we place on the board's potentiometer (AD input channel 2). Since we are not inputting any values on the channel, it will logically continue to trace at '0'. It is evident how we would go about turning the potentiometer on the dev board, but how could we simulate the pot for testing in Debug mode?
8g) Peripherals (A/D Converter, System Tick Timer, and GPIOs) uVision debugger allows you to model the microcontroller's peripherals. With peripheral modeling, it is possible to adjust input states of the peripherals and examine outputs generated from your program. In our Blinky.c program, the peripherals of interest are the AD converter (since we are inputting AD values from AIN2 - pot), the systick timer, and the GPIOs (the output to the LEDs). We will not model the LCD in this lab as it possesses high CPU utilization times and is more for demo purposes. Therefore make sure that #define _USE_LCDremains commentedin the code during debugging. 1.To open the AD Converter window, in the main menu select Peripherals >> A/D Converter. A window will appear similar to that of Fig. 10. 2.To open the System Tick Timer window, in the main menu select Peripherals >> Core Peripherals >> System Tick Timer. A window will appear resembling Fig. 11. 3.To open the GPIO 2 analyzer (LED simulator), select Peripherals >> GPIO Fast Interface >> Port 2. A window will appear as shown in Fig. 12. Also open Port 1, i.e. Peripherals >> GPIO Fast Interface >> Port 1 (as the first 3 LEDs belong to Port1, last 5 belong to Port 2). 4.To open the Debug window and view printf statements in the code, select View >> Serial Windows >> Debug (printf) Viewer.