main.c
来自「PHILIPS LPC76X D/A 实例程序」· C语言 代码 · 共 46 行
C
46 行
/*-----------------------------------------------------------------------------
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 + =
减小字号Ctrl + -
显示快捷键?