sim.ini

来自「stm32初级例程」· INI 代码 · 共 59 行

INI
59
字号
/*----------------------------------------------------------------------------
 * Name:    Sim.ini
 * Purpose: Functions used for simulating peripherals
 * Version: V1.01
 *----------------------------------------------------------------------------
 * This file is part of the uVision/ARM development tools.
 * This software may only be used under the terms of a valid, current,
 * end user licence from KEIL for a compatible version of KEIL software
 * development tools. Nothing else gives you the right to use this software.
 *
 * Copyright (c) 2005-2007 Keil Software. All rights reserved.
 *----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------
  Analog() simulates analog input values given to channel-1 (ADC1.0)
  //下面实际是模拟一个三角波
 *----------------------------------------------------------------------------*/
Signal void Analog (float limit)  {
  float volts;

  printf ("Analog (%f) entered.\n", limit);
  while (1)  
  {                          // forever
    volts = 0;
    while (volts <= limit)  
    {
      // analog input-1
      //ADC1.0输入模拟电压
      ADC1_IN0 = volts;
      
      // wait 0.01 seconds
      //延时0.01秒
      swatch (0.01);
      
      // increase voltage 
      //模拟电压步进增加0.1                   
      volts += 0.1;
    }
    volts = limit;
    while (volts >= 0.0)  
    {
      // analog input-1
      //ADC1.0输入模拟电压
      ADC1_IN0 = volts;
      
      // wait 0.01 seconds
      //延时0.01秒
      swatch (0.01);
      
      // decrease voltage
      //模拟电压步进减少0.1
      volts -= 0.1;
    }
  }
}

//模拟输入电压,最大值是3
Analog(3)

⌨️ 快捷键说明

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