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

📄 startup_sim.ini

📁 This project is created using the Keil ARM CA Compiler. The Logic Analyzer built into the simula
💻 INI
字号:
//
// Generate Saw Tooth Signal on AD Channel 0
//
signal void ADC0_Saw (void)  {
  float volts;        // peak-to-peak volatage
  float frequency;    // output frequency in Hz
  float offset;       // volatge offset
  float duration;     // duration in Seconds
  float val;
  long  i, end, steps;
    
  volts     = 2.0;
  offset    = 0.2;
  frequency = 1400;
  duration  = 0.2;

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

  steps = (100000 * (1/frequency));
  end = (duration * 100000);
  for (i = 0 ; i < end; i++)  {
    val = (i % steps) / ((float) steps);
    ADC0 = (val * volts) + offset;
    swatch (0.00001);                // in 10 uSec increments
  }
}

//
// Generate Sine Wave Signal on AD Channel 0
//
signal void ADC0_Sine (void)  {
  float volts;        // peak-to-peak volatage
  float frequency;    // output frequency in Hz
  float offset;       // volatge offset
  float duration;     // duration in Seconds
  float val;
  long  i, end;  

  volts     = 1.4;
  offset    = 1.6;
  frequency = 1800;
  duration  = 0.1;

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

  end = (duration * 100000);
  for (i = 0 ; i < end; i++)  {
    val = __sin (frequency * (((float) STATES) / CLOCK) * 2 * 3.1415926);
    ADC0 = (val * volts) + offset;
    swatch (0.00001);                // in 10 uSec steps
  }
}

//
// Generates an Square Wave Signal on AD Channel 0
//
signal void ADC0_Square (void)  {
  float volts;        // peak-to-peak volatage
  float frequency;    // output frequency in Hz
  float offset;       // volatge offset
  float duration;     // duration in Seconds
    
  volts     = 0.5;
  offset    = 1.6;
  frequency = 2400;
  duration  = 0.5;

  printf ("Square Wave Signal on AD Channel 0.\n");

  while (duration > 0.0)  {
    ADC0 = volts + offset;
    swatch (0.5 / frequency);
    ADC0 = offset;
    swatch (0.5 / frequency);
    duration -= 1.0 / frequency;
  }
}

//
// Combine the Signals
//
signal void Startup (void)  {
  swatch (1.0);    // wait 1.0 seconds
  ADC0_Saw ();
  swatch (0.3);    // wait 0.3 seconds
  ADC0_Square ();
  swatch (0.6);    // wait 0.6 seconds
  ADC0_Sine ();
}


Startup ();        // Start the Signals

define button "ADC0 Sine Wave",   "ADC0_Sine ()"
define button "ADC0 Saw Tooth",   "ADC0_Saw ()"
define button "ADC0 Square Wave", "ADC0_Square ()"

⌨️ 快捷键说明

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