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

📄 motion_excute.c

📁 基于CC1100和ATMEGA128的无线通信程序
💻 C
字号:
 
 
 void Motion_Init(void)  
  { UINT16 i=0,j=0,t=0,temp=0,temp1,temp2;
    TCCR1B = 0x02; //start Time
	for(t=0;t<50;t++)    
      { for(j=1;j<9;j++)	
 	    {  
		if(j<5)
		{PORTC|=(1<<(j-1));	
        temp2=1500+(j-1)*2500;
		}
		PORTA|=(1<<(j-1));	
        temp1=1500+(j-1)*2500;	
        do{ temp=TCNT1;	
 	    if(temp>temp1)PORTA&=~(1<<(j-1));	
  		if(temp>temp2)PORTC&=~(1<<(j-1));
  	      }while(temp<j*2500);        
  	   }
       TCNT1=0;  
       }  
    TCCR1B = 0x00; //start Time
  } 
 
 
 void Motion_Excute(UINT8 (*angle)[13],UINT16 totalstep,UINT16 cycle_start,UINT16 cycle_number)
  { 
  UINT16 i=0,t=0,j=0;
  UINT16 temp1=0,temp2=0,temp=0; 
  
  TCCR1B = 0x02; //start Timer
  for(i=0;i<cycle_start;i++)
  for(t=angle[i][0];t>0;t--)    
     { TCNT1=0x00;
       for(j=1;j<9;j++)	
       { PORTA|=(1<<(j-1));	
         temp1=(100*angle[i][j]/9+500)+(j-1)*2500;
	     if(j<5)
           {PORTC|=(1<<(j-1));	
            temp2=(100*angle[i][j+8]/9+500)+(j-1)*2500;}
         do{temp=TCNT1;	
 	     if(temp>temp1)PORTA&=~(1<<(j-1));	
  	     if(temp>temp2)PORTC&=~(1<<(j-1));}while(temp<j*2500);        
       }
         TCNT1=0x00;		
    }
do{ 
   for(i=cycle_start;i<totalstep;i++)
   for(t=angle[i][0];t>0;t--) 
     {TCNT1=0x00;
      for(j=1;j<9;j++)	
         {  PORTA|=(1<<(j-1));	
            temp1=(100*angle[i][j]/9+500)+(j-1)*2500;
	        if(j<5)
            {PORTC|=(1<<(j-1));	
             temp2=(100*angle[i][j+8]/9+500)+(j-1)*2500;}
             do{temp=TCNT1;	
 	         if(temp>temp1)PORTA&=~(1<<(j-1));	
  	         if(temp>temp2)PORTC&=~(1<<(j-1));}while(temp<j*2500);    
         }
         TCNT1=0x00;		
      }	 
	 cycle_number--;	 
  } while(cycle_number); 
  TCCR1B = 0x00; //stop Timer
}
  

⌨️ 快捷键说明

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