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

📄 main.c

📁 周立功的EASYARM2131的测试程序
💻 C
字号:
/****************************************Copyright (c)**************************************************
**                               Guangzou ZLG-MCU Development Co.,LTD.
**                                      graduate school
**                                 http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name:			main.c
** Last modified Date:  2004-09-16
** Last Version:		1.0
** Descriptions:		The main() function example template
**
**------------------------------------------------------------------------------------------------------
** Created by:			Chenmingji
** Created date:		2004-09-16
** Version:				1.0
** Descriptions:		The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#include "config.h"

void delay(uint32 dly)
{
	uint32 i ;
 	for(; dly > 0 ; dly --)
		for( i = 0 ; i < 50000 ; i++);
} 

void PC_DispChar(uint8 x,uint8 y,uint8 chr,uint8 color)
{
	UART0_SendByte(0xFF);
	UART0_SendByte(x);
	UART0_SendByte(y);
	UART0_SendByte(chr);
	UART0_SendByte(color);
}

void ISendStr(uint8 x,uint8 y,uint8 color,char *str)
{
	while(1)
	{
		if(*str == '\0')
			break;
		PC_DispChar(x++,y,*str++,color);
		if(x>=80)
		{
			x = 0;
			y++;
		}
	}
}

int main (void)
{// add user source code
	uint32 ADC_Data ;
	char str[20];
	UARTMODE set;
	
	set.datab = 8;
	set.stopb = 1;
	set.parity = 0;
	UART0_Init(115200, set);	
	PINSEL1 = 1 << 28;		

	AD0CR = (1 << 3) |
	        ((Fpclk / 1000000 - 1) << 8)|
	        ( 0 << 16) |
	        (0 << 17) |
	        (1 << 21) |
	        (0 << 22) |
	        (1 << 24) |
	        (0 << 27) ;
	delay(10);
	ADC_Data = AD0DR ;
	while(1)
	{
		AD0CR |= 1 << 24 ;
		while((AD0DR & 0x80000000) == 0);
		AD0CR |= 1 << 24 ;
		while((AD0DR & 0x80000000) == 0);
		ADC_Data = AD0DR ;
		ADC_Data = (ADC_Data >> 6) & 0x3FF ;
		ADC_Data = ADC_Data * 2480 ;
		ADC_Data = ADC_Data / 1024 ;
		sprintf(str,"%4d mV VIN3" ,ADC_Data) ;
		ISendStr(0,0,0x30,str);
		
	}
    
    return 0;
}
/*********************************************************************************************************
**                            End Of File
********************************************************************************************************/

⌨️ 快捷键说明

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