NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

Graph Visualization for MSP430

From Texas Instruments Wiki
Jump to: navigation, search

This page is intented to show an application that demonstrates the graph capabilities of CCSv4 for MSP430 users.

Introduction[edit]

The capability of displaying data on a graphical display inside Code Composer Studio is a well known feature for TI DSP developers. Since the new CCSv4 extends support to the MSP430 family of devices, this capability becomes an interesting and useful feature for displaying data on-the-fly directly from memory buffers and registers. This page details the procedure to perform this task and makes some considerations about the displayed data. It uses (and slightly modifies) the well known ADC12 MSP430F149 example code available on the web.

References[edit]

This page refers to the following documents:

MSP430F149 Datasheet: http://www-s.ti.com/sc/techlit/msp430f149

MSP430F1xx User's Guide: http://www-s.ti.com/sc/techlit/slau049

MSP430x13x, MSP430F14x, MSP430F15x, MSP430F16x code examples: http://focus.ti.com/mcu/docs/mcuprodcodeexamples.tsp?sectionId=96&tabId=1468

How to create Custom Target Configurations: Creating_Custom_Target_Configurations

Q format for fixed point arithmetic article on wikipedia: http://en.wikipedia.org/wiki/Q_(number_format)

Not covered in this document[edit]

Several topics are outside the scope of this document: CCSv4 installation, emulator and hardware configuration, details about the MSP430F149 ADC12 converter, and anything else you can't find here!

How to proceed:[edit]

Download and installation of the required components[edit]

  • If you haven't done so, download and install CCSv4. Make sure the proper MSP430 emulators are installed (the parallel port emulator is not installed by default).
  • Download and unzip the code examples from the reference above; it will extract several C and assembly source files tailored for several MSP430 devices. In this example the file <fet140_adc12_01.c> will be used.

Creating the example project[edit]

  • Inside CCSv4, create a new MSP430 project: go to File -> New -> CCS Project... and name it MSP430_graph. Click Next.
  • Select MSP430 as the Project Type and click Next.
  • No dependent projects are required for this application, therefore click Next.
  • Select MSP430F149 as the Device Variant and click Finish. The project is created and you should see the screen below:
Fig. 1: New project
  • Right-click on the project name MSP430_graph and click on Add Files to Project.... Point to the directory you installed the code examples and select the file <fet140_adc12_01.c>.
  • Double-click on this source file and locate line 31 (check the modified code below). The dividers ADC12DIV0, ADC12DIV1 and ADC12DIV2 will be added to the ADC12CTL1 register in order to slow down the conversion rate. This will make the ADC run at around 5Hz and is just for displaying purposes, since it is impossible to display data if the ADC is running at 200kSPS...

<syntaxhighlight lang='c'>

 ...
 ADC12CTL0 = SHT0_2 + ADC12ON;             // Set sampling time, turn on ADC12
 ADC12CTL1 = SHP + ADC12DIV0 + ADC12DIV1 + ADC12DIV2; // Use sampling timer
 ADC12IE = 0x01;                           // Enable interrupt
 ADC12CTL0 |= ENC;                         // Conversion enabled
 ...

</syntaxhighlight>

  • When the project was created it may have also included a target configuration in the file <MSP430F149.ccxml> that uses the USB emulator. If this does not reflect your hardware please refer to the reference above on how to create or modify a target configuration.
  • Build the project: Menu Project -> Build Active Project. If everything was successful you should have the screen below. Go to the next section.
Fig. 2: Build successful

Configuring the graph display and debugging[edit]

  • Open the debugger and load the project to the board. Menu Target -> Debug Active Project. If everything is ok you should have the screen below:
Fig. 3: Project loaded
  • In the source window locate line 48 and double-click on it to enable a breakpoint. You will see a small blue dot MSP430 graph bkpt bluedot.JPG close to the line number.
  • Right-click on the blue dot and click on Breakpoint Properties.... This will configure the action when the program reaches the breakpoint.
  • At the Property Action, click on its Value and select Refresh All Windows. This will refresh all windows instead of completely halting the program at this point. Check the screen below:
Fig. 4: Breakpoint properties
  • The register ADC12MEM0 contains the result of the conversion for this example program, therefore this is the value needed for displaying in both the graph window and the watch window. Click on Tools -> Graph -> Single Time and configure the options as below:
Property Value
Acquisition Buffer Size 1
Dsp Data Type 16 bit unsigned integer
Q_value 12
Sampling Rate HZ 5
Start Address ADC12MEM0
Time Display Unit s
  • A graph window should appear at the bottom of the screen. If needed, the graph properties can be changed by clicking on the button MSP430 graph properties btn.JPG.
  • To see the actual value of ADC12MEM0 register, click on the tab Watch (should be at the upper right portion of the screen) and click on new. Type *(0x140) which corresponds to the contents of the address 0x140
  • Now simply Run the target! You should see the graph and the watch window updating one sample at a time in animated form.

What is happening with the values displayed in the graph? Why do they look wrong?[edit]

The main reason for this is due to the fact that the display graph does not know the maximum voltage of the ADC; it is actually a normalized value referred to the Q value setting of the graph display (check the Q format reference above).

Because the ADC only reaches 12 bits and the graph display shows 16 bit unsigned integers, the Q value must be set. If the Q value is left to its default value of 0, the Y axis would only show the decimal values corresponding to the ADC output codes (from 0 to 4095).

Therefore, in order to have a better correlation with the ADC voltage input on the graph tool the Q value was set to 12, forcing the graph tool to reach 1 when the ADC data equals to 0xFFF.

This turns the graph values into the normalized values relative to the maximum input voltage of the ADC. For example, if the ADC maximum voltage (AVcc) is 2.8V the display below shows values of 0,2; 0,4; 0,6 and 0,8 that correspond to <math>2.8 \times 0,2 = 0,56V</math>; <math>2.8 \times 0,4 = 1.12V</math>; <math>2.8 \times 0,6 = 1.68V</math>; <math>2.8 \times 0,8 = 2.24V</math>

Fig. 5: Final display graph

Considerations and possible issues[edit]

  • There are plans to implement a feature that sets the maximum input on the graph tool to avoid the use of normalized values.
  • Sometimes changing the graph tool properties while running the code takes a long while to update it. The root cause was not yet found.
  • The graph display tool has the auto scaling enabled by default. This leads to highly variable measurements as the input is settled, however they refer simply to missing codes or noise in the input. This is similar to a measurement done using an auto-range oscilloscope with AC coupling and a pre-set DC level. As an example check the screen below, where a constant input voltage leads to a variable input voltage from 0,1885 through 0,1895
    • New for CCSv4 Release Candidate!!! The auto scale can be disabled; just right-click on the graph window and uncheck the option Auto Scale.


Fig. 6: Auto scale effect on values


--Rsjsouza 15:54, 28 April 2009 (CDT)

E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Graph Visualization for MSP430 here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Graph Visualization for MSP430 here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article Graph Visualization for MSP430 here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article Graph Visualization for MSP430 here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article Graph Visualization for MSP430 here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Graph Visualization for MSP430 here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Graph Visualization for MSP430 here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article Graph Visualization for MSP430 here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article Graph Visualization for MSP430 here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity