Keil Logo

µVISION DEBUGGER: USING THE AINX VTREGS


Information in this article applies to:

  • C166 Version 4
  • C251 Version 3
  • C51 Version 6
  • µVision Version 2

QUESTION

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

ANSWER

When simulating a target microcontroller, the Keil µVision 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.\n", 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\n", 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\n", i * 90.0, sine); */
      ain0 = ((sine + 1.0) / 2.0) * limit;
      twatch (2000000);
    }
  }
}

SEE ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Monday, June 28, 2004


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.