3.2.12 Data Polling
Now see how Data Visualizer can poll variables from
the target and display their values in graphical form.
Important: Data polling is only available when
Data Visualizer is run as an extension within Atmel Studio. This is because it needs
to access the debug system on the device through the Atmel Studio debugger
backend.
First, add a few lines of code containing variables to poll. Todo: Open
ui.c and add two global variables to the top of the file.
volatile uint32_t write_count = 0; volatile uint32_t read_count = 0;
Important: Declaring
variables you are interested in polling as volatile will ensure that they are placed
in SRAM and that their values will not be cached in registers by the compiler.
Registers cannot be polled, only SRAM locations.
Tip: Data polling operates on
absolute SRAM locations. It is thus advised to use global variables for this purpose
so that they are always available at the same location in SRAM. Polling locations in
the stack can yield unpredictable results based on the stack context at the time of
polling.
Todo: Modify the two ̔startʼ functions in ui.c to increment read and write counters on
each access started.
void ui_start_read(void) { port_pin_set_output_level(EXT1_PIN_GPIO_0, true); read_count++; }
void ui_start_write(void) { port_pin_set_output_level(EXT1_PIN_GPIO_1, true); write_count++; }
Todo:
For data polling functionality, enable the Code Profiling interface.
- Build the project/solution (F7)
- Open Data Visualizer
- Connect
Todo:
Data polling operates on SRAM locations, so to find out where variables are
located in SRAM we need to use the Atmel Studio Watch window. - Start the Data Visualizer session
- Launch the debug session using Start Debugging and Break (Alt + F5)
Todo:
Switch back to the Data Visualizer to set up the Code
Profiling interface and to connect the two variables to a graph.- Locate the two global variables added to ui.c
- Right-click each variable and select Add to Watch
- Examine the type field of each variable in the Watch window to find its location