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

📄 10._c

📁 这里有11个用ICCAVR开发的源代码,经DEMO板调试后已经通过.
💻 _C
字号:
//ICC-AVR application builder : 2005-3-11 15:28:29
// Target : M48
// Crystal: 8.0000Mhz

#include <iom48v.h>
#include <macros.h>
unsigned char	   size;

void port_init(void)
{
 PORTB = 0xFF;
 DDRB  = 0xff;
 PORTC = 0x7F; //m103 output only
 DDRC  = 0x00;
 PORTD = 0xFF;
 DDRD  = 0xF0;
}

//call this routine to initialize all peripherals
void init_devices(void)
{
 //stop errant interrupts until set up
 CLI(); //disable all interrupts
 port_init();

 MCUCR = 0x00;
 EICRA = 0x00; //extended ext ints
 EIMSK = 0x00;
 
 TIMSK0 = 0x00; //timer 0 interrupt sources
 TIMSK1 = 0x00; //timer 1 interrupt sources
 TIMSK2 = 0x00; //timer 2 interrupt sources
 
 PCMSK0 = 0x00; //pin change mask 0 
 PCMSK1 = 0x00; //pin change mask 1 
 PCMSK2 = 0x00; //pin change mask 2
 PCICR = 0x00; //pin change enable 
 PRR = 0x00; //power controller
 SEI(); //re-enable interrupts
 //all peripherals are now initialized
}

/*前行*/
void	forward(void)
{
 PORTD = 0X9F;
 PORTB = 0XF8;
}

/*停止*/
void	stop(void)
{
 PORTD = 0XFF;
 PORTB = 0XFF;
}

void mic_startup()
{//声控启动程序运行
 unsigned char mic_in;
 while(1)//等待PB2按键按下	
   {	  //无键按下等待
    mic_in=PINC & 0x20;     //pc5=0
    if(mic_in==0){break;}
   }//有键按下运行下面的程序
}

/*主程序*/
void   main()
{
 unsigned char i;
 init_devices();
demand:
	   mic_startup();
 //while(1){
 //i = PINC&20;
 //if(i == 0){
 size++;
 //break;
 //}
 //}
 while(1)
 {
 if(size==1)
 		{
 		 forward();}
  else	if(size==2)
  		   {
 		   	stop();
			size=0;}
  goto	 demand;
 }
}
 

⌨️ 快捷键说明

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