main.c

来自「Hitex LPC2100 insider guide source code」· C语言 代码 · 共 39 行

C
39
字号
#include <math.h>
#include <LPC213x.h>
unsigned int input[50];
unsigned int output[50]
unsigned int impulse[10]

void main(void)
{
unsigned int val;


PINSEL1 = 0x00080000;			//Configure pin 0.25 as the DAC pin
VPBDIV 	= 0x01;					//Set the Pclk to 60 Mhz
T0PR 	= 0x0000000;			//Load prescaler
T0TCR 	= 0x00000002;			//Reset counter and prescaler
T0MCR 	= 0x00000003;			//On match reset the counter and generate an interrupt
T0MR0	= 0x00000668;			//Set the cycle time
T0MR1	= 0x0000000c;			// Set 50% duty cycle
T0EMR  	= 0x00000042;			//On match clear MAT1
T0TCR 	= 0x00000001;

AD0CR   = 0x00270601;    			// Setup A/D: 10-bit AIN0 @ 3MHz 
AD0CR  |= 0x01000000;    			// Start A/D Conversion 

while(1)
{
		  
do
{
    val = AD0DR;                   // Read A/D Data Register 
}        
while ((val & 0x80000000) == 0);  //Wait for the conversion to complete

DACR   = val;					  //Write the converted value to the DAC register
}
}


⌨️ 快捷键说明

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