• 大小: 5.82MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-11-21
  • 语言: 其他
  • 标签: c8051f020  

资源简介

c8051f020的学习例程,c8051f020学习必备!!!

资源截图

代码片段和文件信息




#include“c8051f020.h“
#include“intrins.h“


#define SYSCLK  22118400
#define SAMPLERATE 5000


unsigned  sum=0;
float vc;
xdata unsigned sample[5];
unsigned char flag=0;

void SysclkInit(void)
{

unsigned int i;

OSCXCN=0x67;

for(i=0;i<256;i++);
while(!(OSCXCN&0x80));

OSCICN=0x88;

}






void ADC0Init(void)
{
ADC0CN=0x04; //ADC0禁止;正常工作模式;定时器3溢出ADC0转换开始;ADC0转换数据右对齐
REF0CN=0x07; //使能温度传感器,片内VREF,和VREF输出缓冲器
AMX0SL=0x00; //选择AIN0作为ADC多路转换输出
ADC0CF=(SYSCLK/2500000)<<3; //ADC转换时钟2.5MHZ
ADC0CF&=~0x07; //PGA增益=1
EIE2&=~0x02; //禁止ADC0中断
AD0EN=1; //使能ADC0
}


void Timer3Init(int counts)
{
TMR3CN=0x02; //停止定时器3;清除TF3;使用系统时钟作为时基
TMR3RL=-counts; //初始化重装值
TMR3=0xffff; //立即开始重装
EIE2&=~0x01; //禁止定时器3中断
TMR3CN|=0x04; //启动定时器3

}





void main(void)
{
unsigned char j;


WDTCN=0xde;
WDTCN=0xad;

SysclkInit();

// PortInit();
Timer3Init(SYSCLK/SAMPLERATE);
ADC0Init();
ADC0CN|=0x80;
EA=1;
EIE2|=0x02;
while(1)
{
if(flag)
{
flag=0;
for(j=0;j<5;j++)
sum=sum+sample[j];
sum=sum/5;
vc=((float)sum/4096)*2.50;
}
_nop_();
}


}

void ADC0_ISR(void) interrupt 15 using 3
{

static unsigned char i=0;
AD0INT=0; //清除ADC0转换结束标志
sample[i]=ADC0; //读和存储ADC0值
i++;
if(i==5)
{
flag=1;
i=0;
EIE2&=~0x02;
}
}




 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     869702  2009-08-17 20:24  c8051f020例程\020应用笔记.pdf

     文件       6134  2009-08-19 13:59  c8051f020例程\ADC0\ADC0

     文件       1515  2009-08-17 10:19  c8051f020例程\ADC0\ADC0.c

     文件       3138  2009-08-19 13:59  c8051f020例程\ADC0\ADC0.hex

     文件        103  2009-08-19 13:59  c8051f020例程\ADC0\ADC0.lnp

     文件       4692  2009-08-19 13:59  c8051f020例程\ADC0\ADC0.LST

     文件       9485  2009-08-19 13:59  c8051f020例程\ADC0\ADC0.M51

     文件       5185  2009-08-19 13:59  c8051f020例程\ADC0\ADC0.OBJ

     文件       2909  2009-08-26 09:33  c8051f020例程\ADC0\ADC0.Opt

     文件        187  2009-08-26 09:33  c8051f020例程\ADC0\ADC0.plg

     文件       2155  2009-08-15 15:58  c8051f020例程\ADC0\ADC0.Uv2

     文件       2911  2009-08-19 14:00  c8051f020例程\ADC0\ADC0_Opt.Bak

     文件       2134  2009-08-15 15:26  c8051f020例程\ADC0\ADC0_Uv2.Bak

     文件      16700  2009-07-25 12:04  c8051f020例程\ADC0\c8051F020.h

     文件        603  2009-07-22 15:20  c8051f020例程\ADC0\LedShow.c

     文件       2337  2009-07-22 15:42  c8051f020例程\ADC0\LedShow.LST

     文件       2794  2009-07-22 15:42  c8051f020例程\ADC0\LedShow.OBJ

     文件         32  2009-07-25 08:12  c8051f020例程\ADC0\my.h

     文件       5115  2002-04-16 15:32  c8051f020例程\ADC0\STARTUP.A51

     文件      11674  2009-08-19 13:59  c8051f020例程\ADC0\STARTUP.LST

     文件        749  2009-08-19 13:59  c8051f020例程\ADC0\STARTUP.OBJ

     文件       1034  2009-07-25 08:49  c8051f020例程\ADC0\UART0.c

     文件       2433  2009-07-25 12:06  c8051f020例程\ADC0\UART0.LST

     文件       1477  2009-07-25 12:06  c8051f020例程\ADC0\UART0.OBJ

     文件      10885  2001-09-03 19:14  c8051f020例程\ADC0_Buf1\ADC0_Buf1.c

     文件       9802  2001-09-03 19:13  c8051f020例程\ADC0_Int1\ADC0_Int1.c

     文件      10368  2001-09-03 19:16  c8051f020例程\ADC0_Int2m\ADC0_Int2m.c

     文件      10893  2001-09-03 19:21  c8051f020例程\ADC0_OSA1\ADC0_OSA1.c

     文件       8122  2001-09-04 11:02  c8051f020例程\ADC0_Poll1\ADC0_Poll1.c

     文件     100261  2009-08-10 15:33  c8051f020例程\an022.pdf

............此处省略246个文件信息

评论

共有 条评论