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

📄 main.c

📁 PHILIPS LPC76X D/A 实例程序
💻 C
字号:
/*-----------------------------------------------------------------------------
The following program generates sawtooth waves on the DAC outputs of the
Philips LPC Devices.  This code was compiled and tested using the
Keil Software PK51 Professional Developer's Kit V6.10a.
-----------------------------------------------------------------------------*/
#include <REG769.H>

void main (void)
{
/*-----------------------------------------------
Disable the A/D Converter (this is required for
DAC0)
-----------------------------------------------*/
ADCI = 0;  /* Clear A/D conversion complete flag */
ADCS = 0;  /* Clear A/D conversion start flag */
ENADC = 0; /* Disable the A/D Converter */

/*-----------------------------------------------
Set P1.6 and P1.7 to Input Only (Hi Z).
-----------------------------------------------*/
P1M2 &= ~0xC0;
P1M1 |=  0xC0;

/*-----------------------------------------------
Enable the D/A Converter
-----------------------------------------------*/
ENDAC0 = 1;
ENDAC1 = 1;

while (1)
  {
  unsigned int i;

/*-----------------------------------------------
Create a sawtooth wave on DAC0 and the opposite
sawtooth wave on DAC1.
-----------------------------------------------*/
  for (i = 0; i < 0x100; i++)
    {
    DAC0 =  i;
    DAC1 = 0xFF - i;
    }
  }
}

⌨️ 快捷键说明

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