⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debug.ini

📁 c8051f320系列单片机使用adc的c源程序。
💻 INI
字号:
/*-------------------------------------------------------------
This file set the analog inputs for the A/D to different
values depending on the button clicked
-------------------------------------------------------------*/
define float my_VREF;
my_VREF = 5.0;

/*-------------------------------------------------------------
Create buttons -to set the analog inputs to 0.
               -to set the analog inputs to VREF.
               -to set different analog inputs.
-------------------------------------------------------------*/

define button "Inputs = 0V" ,          "Set_Inputs(0.0);"
define button "Inputs = High" ,        "Set_Inputs(my_VREF);"
define button "Different A/D Inputs" , "Different_Inputs();"
define button "Sine Wave (AIN10)" ,     "AIN10_Sine(my_VREF);"
define button "Sawtooth (AIN11)" ,      "AIN11_Saw (my_VREF);"
define button "Stop Signals" ,         "signal kill AIN10_Sine;signal kill AIN11_Saw;"


/*-------------------------------------------------------------
The following functions will set the imputs of the analog
converter to 0, limit, or different values
-------------------------------------------------------------*/
func void Set_Inputs (float volt) {
  AIN10 = AIN11 = AIN12 = AIN13 = AIN14 = AIN15 = AIN16 = AIN17 = 
  AIN20 = AIN21 = AIN22 = AIN23 = AIN24 = AIN25 = AIN26 = AIN27 = 
  AIN30 = volt;
}


func void Different_Inputs () {
  AIN10 = 0.2;
  AIN11 = 0.4;
  AIN12 = 0.6;
  AIN13 = 0.8;
  AIN14 = 1.2;
  AIN15 = 1.4;
  AIN16 = 1.6;
  AIN17 = 1.8;
  AIN20 = 2.2;
  AIN21 = 2.4;
  AIN22 = 3.6;
  AIN23 = 3.8;
  AIN24 = 4.2;
  AIN25 = 4.4;
  AIN26 = 4.6;
  AIN27 = 4.8;
  AIN30 = 5.0;
}


/*----------------------------------------------------------------------
The following function generates analog voltages in a sine wave pattern.
Use the built-in Logic analyzer to view the output as a sine wave.
----------------------------------------------------------------------*/
signal void AIN10_Sine ( float sn_limit )  {

  float frequency;    // output frequency in Hz
  float offset;       // voltage offset
  float val;

  offset    = sn_limit / 2;
  frequency = 1800;

  printf ("Sine Wave Signal on AIN1 Channel 0.\n");

  while (1) {
    val = __sin (frequency * (((float) STATES) / CLOCK) * 2 * 3.1415926);
    AIN10 = (val * (sn_limit / 2)) + offset;
    swatch (0.00001);                // in 10 uSec steps
  }
}

/*-----------------------------------------------------------------
The following function generates a sawtooth signal pattern for AIN11.  
-----------------------------------------------------------------*/
signal void AIN11_Saw (float st_limit)  {
  float frequency;    // output frequency in Hz
  float val;
  long  i, steps;
    
  frequency = 1400;

  printf ("Saw Tooth Signal on AD Channel 1\n");

  steps = (100000 * (1/frequency));
  for (i = 0 ; ; i++)  {             // Runs signal continuously
    val = (i % steps) / ((float) steps);
    AIN11 = (val * st_limit);
    swatch (0.00001);                // in 10 uSec increments
  }
}


/*-------------------------------------------------------------
-------------------------------------------------------------*/



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -