虫虫首页| 资源下载| 资源专辑| 精品软件
登录| 注册

PORT_Init

  • C8051控制DA void OSCILLATOR_Init (void) void PORT_Init (void) void Delay (int) void init_da (vo

    C8051控制DA void OSCILLATOR_Init (void) void PORT_Init (void) void Delay (int) void init_da (void) void da_conv()

    标签: void OSCILLATOR_Init PORT_Init init_da

    上传时间: 2016-10-13

    上传用户:libinxny

  • c8051f330 C程序源代码

    //------------------------------------------------------------------------------------//此程序为ADC转换程序,可以选择向ADC0BUSY写1或用定时器0,1,2,3作为ADC的启动信号。////------------------------------------------------------------------------------------//头文件定义//------------------------------------------------------------------------------------//#include <c8051f330.h>               #include <stdio.h> //-----------------------------------------------------------------------------// 定义16位特殊功能寄存器//----------------------------------------------------------------------------- sfr16 ADC0     = 0xbd;                sfr16 TMR0RL   = 0xca;                                                                                               sfr16 TMR1RL   = 0xca;                 sfr16 TMR2RL   =0xca;                 sfr16 TMR3RL   =0xca;               sfr16 TMR0     = 0xCC;              sfr16 TMR1     = 0xCC;                sfr16 TMR2     = 0xcc;               sfr16 TMR3     = 0xcc;               //-----------------------------------------------------------------------------// 全局变量定义//-----------------------------------------------------------------------------char i;int result;                       //-----------------------------------------------------------------------------//定义常量//-----------------------------------------------------------------------------#define SYSCLK       49000000        #define SAMPLE_RATE  50000             //------------------------------------------------------------------------------------// 定义函数//------------------------------------------------------------------------------------void SYSCLK_Init (void);void PORT_Init (void);void Timer0_Init (int counts);void Timer1_Init (int counts);void Timer2_Init (int counts);void Timer3_Init (int counts);void ADC0_Init(void);void ADC0_ISR (void);void ADC0_CNVS_ADC0h(void);//------------------------------------------------------------------------------------// 主程序//------------------------------------------------------------------------------------ void main (void) {       int ADCRESULT[50] ;  int k;                     PCA0MD &= ~0x40;                       // 禁止看门狗                   SYSCLK_Init ();                        PORT_Init ();    Timer0_Init (SYSCLK/SAMPLE_RATE);     //Timer1_Init (SYSCLK/SAMPLE_RATE);     //选择相应的启动方式   //Timer2_Init (SYSCLK/SAMPLE_RATE);    //Timer3_Init (SYSCLK/SAMPLE_RATE);          ADC0_Init();   EA=1;   while(1)            {     //ADC0_CNVS_ADC0h();  k=ADC0;    ADCRESULT[i]=result;                   //此处设断点,观察ADCRESULT的结果          }   }

    标签: c8051f330 C程序 源代码

    上传时间: 2013-10-13

    上传用户:SimonQQ