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

📄 debug.ini

📁 这个文件是西门子16位单片机从c166上的一些应用程序的源代码
💻 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 2.5.
               -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 (AN0)" ,      "AN0_Sine(my_VREF);"
define button "Sawtooth (AN1)" ,       "AN1_Saw (my_VREF);"
define button "Stop Signals" ,         "signal kill AN0_Sine;signal kill AN1_Saw;"


/*-------------------------------------------------------------
The following functions will set the imputs of the analog
converter to 0, 2.5, or differnt values
-------------------------------------------------------------*/
func void Set_Inputs (float volt) {
  AN0 = AN1 = AN2 = AN3 = AN4 = AN5 = AN6 = AN7 =
  AN12 = AN13 = AN14 = AN15 = volt;
}


func void Different_Inputs () {
  AN0 = 0.2;
  AN1 = 0.4;
  AN2 = 0.6;
  AN3 = 0.8;
  AN4 = 1;
  AN5 = 1.3;
  AN6 = 1.6;
  AN7 = 1.9;
  AN12 = 3.6;
  AN13 = 4;
  AN14 = 4.4;
  AN15 = 4.8;
}

/*----------------------------------------------------------------------
The following function generates anolog voltages in a sine wave pattern.
Use the built-in Logic analyzer to view the output as a sine wave.
----------------------------------------------------------------------*/
signal void AN0_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 AD Channel 0.\n");

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

/*-----------------------------------------------------------------
The following function generates a sawtooth signal pattern for AN1.  
-----------------------------------------------------------------*/
signal void AN1_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);
    AN1 = (val * st_limit);
    swatch (0.00001);                // in 10 uSec increments
  }
}


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

⌨️ 快捷键说明

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