📄 ad_test.c
字号:
/*********************************************************************************************
* File: ad_test.c
* Author: embest
* Desc: ad_test source code
* History:
*********************************************************************************************/
#include "44b.h"
#include "44blib.h"
/*------------------------------------------------------------------------------------------*/
/* function declare */
/*------------------------------------------------------------------------------------------*/
void adc_test(void);
/*********************************************************************************************
* name: Main
* func: c code entry
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void Main(void)
{
sys_init(); // Initial 44B0X's Interrupt,Port and UART
//user interface
uart_printf("\n\r Embest Arm EduKit II Evaluation Board");
uart_printf("\n S3C44B0x ADC Conversion Test Example\n");
adc_test(); // Test start
}
/*********************************************************************************************
* name: adc_test
* func: test adc
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void adc_test(void)
{
int nAdcpsr;
// Initialize adc
rCLKCON = 0x7ff8;
rADCCON = 0x1 | (0<<2); // Enable ADC
delay(100); // delay for 10ms for ADC reference voltage stabilization.
//set ADCPSR value
uart_printf( "Input ADCPSR value (1 - 255):" );
nAdcpsr = uart_getintnum();
rADCPSR = nAdcpsr;
uart_printf( "ADC conversion freq. = %dHz\n", (int)(MCLK/(2.*(nAdcpsr+1.))/16.) );
//AIN2 AD conversion
uart_printf("\nPlease press 'Enter' to convert\n");
while( uart_getch() != '\n' )
{
rADCCON = 0x1 | (0x2<<2); // AIN2
while( !(rADCCON&0x40) ); // wait conversion finish
uart_printf( "Ain2 = 0x%03x\n", rADCDAT );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -