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

📄 adc10.c

📁 dc servo using dspic30f
💻 C
字号:
//---------------------------------------------------------------------
//	File:		adc10.c
//
//	Written By:	Lawrence Glaister VE7IT
//
// Purpose: routines to setup and use 10 bit A/D ports
//      // 
//---------------------------------------------------------------------
//
// Revision History
//
// 18 Mar 2006 -- first version
//---------------------------------------------------------------------- 
#include "dspicservo.h"
#include <adc10.h>
extern volatile unsigned short int timer_a2d;

/************************************************************************
* Function Name     : ADC10_read
* Description       : This function reads from ch0 AN0
* Parameters        : 
* Return Value      : unsigned int
*************************************************************************/
unsigned int ADC10_read(void)
{	
//	printf("adc10-read  starting\r\n");
	timer_a2d = 5;				// 2 ticks of 100us clock
	while ( timer_a2d );		// delay for sample time
//	printf("adc10-read after sample delay\r\n");
	ADCON1bits.SAMP = 0;		// start converting
	while (!ADCON1bits.DONE);	// wait for conversion to complete (12fcy)
//	printf("adc10-read after conversion complete\r\n");
	return ADCBUF0;
}

/*********************************************************************
* Function Name     : setup_ADC10
* Description       : Configures the ADC. This includes :
                    

⌨️ 快捷键说明

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