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

📄 t1.h

📁 1602液晶显示模块
💻 H
字号:
//TIMER1 initialize - prescale:1
// WGM: 0) Normal, TOP=0xFFFF
char TCOV1=0;
void timer1_init(void)
{
 TCCR1B = 0x00; //stop
 TCNT1H = 0xB1; //setup
 TCNT1L = 0xE0;
 OCR1AH = 0x4E;
 OCR1AL = 0x20;
 OCR1BH = 0x4E;
 OCR1BL = 0x20;
 OCR1CH = 0x4E;
 OCR1CL = 0x20;
 ICR1H  = 0x00;
 ICR1L  = 0x00;
 TCCR1A = 0x00;
 TCCR1B = 0x00; //start Timer
}

#pragma interrupt_handler timer1_ovf_isr:15
void timer1_ovf_isr(void)
{TCCR1B = 0x00; //start Timer
 //TIMER1 has overflowed
 TCOV1=1;
}
void set_Timer1(int cnt)
   { int temp=cnt>>8;
	 TCNT1H=temp&0xff;
     TCNT1L=cnt&0xff;
	 TCCR1B = 0x01; //start Timer
	//while(!TCOV1)
	// {
	// delay_nus(10);
	// TCCR1B = 0x00; //stop
	 //TCCR1B = 0x00; //stop
	 //delay_nms(20);
	// }
   }
void calculate_TCNT(float *degr)
  {
   int t;float temp;
  //..........................................
  //由相位计算出TCNT
  temp=(*degr)/Phase1[7];//frequence=Phase1[7] 
  temp=5555.55*temp;
  t=65535-(int)temp; 
  BCDtoArray(t,led_buff);
  display();
  //..........................................
  set_Timer1(t);          //启动定时器
  while(!TCOV1);            //等待T1益出
   TCOV1=0;
  }
void SET_Phase()
 { float *p=Phase1;
   PORTB=0X00;
   
  
 }

⌨️ 快捷键说明

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