/*
*
* 文件名: LPLD_ADC.c
* 用途: 模數(shù)轉(zhuǎn)換示例程序
*
* LPLD_K60 Card 硬件配置說明:
* 模擬信號(hào)由PTA7引腳輸入
*
*
*/
#include "common.h"
#include "HAL_ADC.h"
//函數(shù)聲明
void delay(void);
//全局變量
uint16 Adc0_Result;
/********************************************************************/
void main (void)
{
/*
初始化 ADC0
十位精度
單端輸入
*/
LPLD_ADC_Init(ADC0, MODE_10, CONV_SING);
while(1)
{
Adc0_Result = LPLD_ADC_SE_Get(ADC0, 10); // 取得AD4b的AD值,引腳輸入PTA7
printf("\n\r0x%X",Adc0_Result); // 16進(jìn)制輸出到串口顯示
delay();
}
}
/*
* 延時(shí)一段時(shí)間
*/
void delay()
{
unsigned int i, n;
for(i=0;i<30000;i++)
{
for(n=0;n<200;n++)
{
asm("nop");
}
}
}
/********************************************************************/
|