ARM Technical Support Knowledge Articles

USING THE AINX VTREGS

Applies to: uVision Debugger

Answer


Information in this article applies to:


QUESTION

What are the AINx VTReg and how do I use it?

ANSWER

When simulating a target microcontroller, the Keil uVision Debugger provides Virtual Target Registers (VTRegs) to allow you to provide input to the pins of the simulated device.

The AINx VTRegs represent the inputs to the analog input pins of the MCU for analog input 0, 1, 2, and so on.

So, if you have configured the analog inputs, the following commands (typed in the debugger's Command Window) input the voltages specified.

AIN0 = 0.000  /* Analog Input 0 = 0.000 volts */
AIN1 = 2.500  /* Analog Input 0 = 2.500 volts */
AIN2 = 4.999  /* Analog Input 0 = 4.999 volts */

You may create signal functions that inject waveforms into the analog inputs. For example:

signal void analog0_sine (float limit)  {
  float i;
  float sine;

  printf ("Analog0_sine (%f) entered.
", limit);

  while (1)  {          /* forever */

    /* SIN swings from -1 to 1 so... adjust it to scale from 0 to 1 */
    /* This is a Taylor series that calculates SIN */
    /* i is the angle where -1.0 = -pi/2 and 1.0 = +pi/2 */

    for (i = -1.0; i < 1.0; i += 0.01) {
      sine = i * (1.570796329
           - i * i * (0.6459640960
           - i * i * (0.07969262599
           - i * i * (0.004681754102
           - i * i * (0.0001604411842)))));
/*      printf ("SIN(%4f) = %6f
", i * 90.0, sine); */
      ain0 = ((sine + 1.0) / 2.0) * limit;
      twatch (2000000);
    }

    for (i = 1.0; i > -1.0; i -= 0.01) {
      sine = i * (1.570796329
           - i * i * (0.6459640960
           - i * i * (0.07969262599
           - i * i * (0.004681754102
           - i * i * (0.0001604411842)))));
/*      printf ("SIN(%4f) = %6f
", i * 90.0, sine); */
      ain0 = ((sine + 1.0) / 2.0) * limit;
      twatch (2000000);
    }
  }
}

SEE ALSO

Article last edited on: 2004-06-28 11:16:40

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential