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

📄 timer.c

📁 S3c2410下ADC[LTC1867]的驱动程序,在LCD上可以直接显示读取的AD数据
💻 C
字号:
#include "2410addr.h"
#include "2410lib.h"
#include "def.h"

uint LED_ct1,LED_ct2;
uchar t0flag,ADC_refresh_flag;

 void __irq timer0_int(void)
  {
     ClearPending(BIT_TIMER0);
     t0flag=!t0flag;
     
     rGPBCON = rGPBCON &~(3<<0)|(1<<0);  //GPB0 as output  
      
     ADC_refresh_flag=1;
      
     LED_ct1++;
     if(LED_ct1>2)
       {
           LED_ct1=0;   
                if(t0flag)
                   { rGPFDAT=(rGPFDAT&0x0F)|0xf0;  } //LED1-4 on  
             else
                    {rGPFDAT=(rGPFDAT&0x0F)|0x00;     }  //LED1-4 off 
       }                 
 }
 
 void timer0_init()  //time=0.5s   0x7ffff
  {
    rGPBUP=rGPBUP&~1;
     rGPBCON = rGPBCON &~(3<<0)|(1<<0);  //GPB0 as output
     rTCFG0 = rTCFG0 & ~0xf|(255<<0);  //prescaler = 255
     //PCLK=50M  50/4=12.5M=0.08us(prescaler=0)  max_resolution=20.48us
     rTCFG1 = rTCFG1 &~( 0xf<<0)|(1<<0);     //timer0,divider = 1/4  
  	//rTCFG0 = rTCFG0 & ~0xff|15; //prescaler = 15
	//rTCFG1 = rTCFG1 & ~0xf|2;//divider = 1/8
    // rTCFG1 = rTCFG1 & ~0xf|2; 
     rTCNTB0=0x989; //0.5s initial value  0.5S=0xbebc  50ms=0x989  1312=0.1s
   // rTCMPB0 = rTCNTB0>>1;
     //auto-reload, inv-off, update TCNTB0&TCMPB0, start timer 0
     rTCON = rTCON & ~0xf|(1<<3)|(0<<2)|(1<<1)|(1<<0);
     rTCON &= ~(1<<1);	//clear manual update bit
     
     EnableIrq(BIT_TIMER0);
     pISR_TIMER0 =(unsigned) timer0_int;
  }

⌨️ 快捷键说明

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