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

📄 lpc_adc.c

📁 给大家提供一个在inram/exram中调试的示例,在周公的lpc2200上调试过.
💻 C
字号:
/***********************************************************************
 *         Philps Semiconductor Software Support
 *         Embest info&Tech Co. Software Support
 *---------------------------------------------------------------------------
 * The software is delivered "AS IS" without warranty or condition of any
 * kind, either express, implied or statutory.  everybody can use it as 
 * it is opened and without copyright. We will not take any law responsibility
 * for any problem produced by using this software.
 *---------------------------------------------------------------------------
 *    File name: 	LPC_Adc.c
 *    Description: 	Define API for A/D Converter
 *
 *    History:
 *    1. Date: 		Nov 20, 2004
 *       Author: 	Shawn Zhang
 *       Description: Create
 *
 *	$Revision: 1.0 $
 **********************************************************************/

#include "LPC_Adc.h"

/*************************************************************************
 * Function Name: ADC_Init
 * Parameters: lpc_uint8 PortNum
 *			
 * Return: int 
 *             	0: success
 *			non-zero: error number
 * Description: Initialize ADC configuration and start conversion at once. And now the
 *				function have only complete softwart control but not BURST.
 *  
 *************************************************************************/
int ADC_Init(lpc_uint8 PortNum)
{
	lpc_uint8 clkdiv;

	clkdiv = (SYS_GetFpclk() / ADC_MAXCLK) -1;

	ADCR = PortNum | (clkdiv << ADCR_CLKDIV_BIT) |(1<<ADCR_PDN_BIT)
			| (1<<ADCR_START_BIT); 
	return 0;
}

/*************************************************************************
 * Function Name: ADC_GetREGValue_ADDR
 * Parameters: void
 * Return: unsigned long 
 *
 * Description: Get A/D data register value
 *  
 *************************************************************************/
unsigned long ADC_GetREGValue_ADDR(void)
{
	while(!(ADDR & ADDR_DONE));
	return (ADDR>>ADDR_DATA_BIT) & 0x3FF; // 10 bits
}

⌨️ 快捷键说明

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