www.pudn.com > STC89C52.rar > MyTask.c, change:2011-06-12,size:1845b


 
#include "Device.h" 
unsigned char timer0h,timer0l,time; 
unsigned char const numcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};// 显示段码值0123456789 
unsigned char code seg[]={0,1,2,3,4,5,6,7};//分别对应相应的数码管点亮 
unsigned char L_value[8] = {0x0E, 0x0C, 0x0D, 0x09, 0x0B, 0x03, 0x07, 0x06}; 
unsigned char code F_Rotation[4]={0x11,0x12,0x14,0x18};//正转表格 
unsigned char code B_Rotation[4]={0x10,0x08,0x040,0x02};//反转表格 
unsigned char i=0; 
unsigned char k,j=0; 
void delay(unsigned int cnt)//延时 
{ 
 while(--cnt); 
} 
 
void MyTask1(void *ppdata) 
{     
      ppdata=ppdata; 
	  for(;;) 
       { 
       P0=numcode[j];//取显示数据 
	   P2=seg[j];  //取段码 
	   OSTimeDly(6);  
            
	   j++; 
	   if(8==j) 
	     j=0; 
		} 
} 
 
 
void MyTask2(void *ppdata) 
{ 
	ppdata=ppdata; 
 
	for(;;) 
    {P10=0; 
	 OSTimeDly(42); 
	 P10=1; 
	 OSTimeDly(42); 
 
    }     
} 
 
void MyTask3(void *ppdata) 
{ 
   ppdata=ppdata; 
 while(1) 
 { 
  for(i=0;i<4;i++)      //4相 
     { 
     P3=F_Rotation[i];  //输出对应的相 可以自行换成反转表格 
     delay(3000);  //改变这个参数可以调整电机转速 
	 OSTimeDly(0); 
	 } 
  } 
  
} 
 
/* 
void MyTask4(void *ppdata) 
{ 
	ppdata=ppdata; 
 
	for(;;) 
    { 
		LED4=!LED4; 
 
		//OSTimeDlyHMSM(0,0,2,500); 
 
		OSTimeDly(OS_TICKS_PER_SEC); 
    }     
} 
 
 
void MyTask5(void *ppdata) 
{ 
	ppdata=ppdata; 
 
	for(;;) 
    { 
		LED5=!LED5; 
 
		OSTimeDlyHMSM(0,0,3,0); 
    }     
} 
 
void MyTask6(void *ppdata) 
{ 
	ppdata=ppdata; 
 
	for(;;) 
    { 
		LED6=!LED6; 
 
		OSTimeDlyHMSM(0,0,3,500); 
    }     
} 
 
void MyTask7(void *ppdata) 
{ 
	ppdata=ppdata; 
 
	for(;;) 
    { 
		LED7=!LED7; 
 
		OSTimeDlyHMSM(0,0,4,0); 
    }     
} 
 
void MyTask8(void *ppdata) 
{ 
	ppdata=ppdata; 
 
	for(;;) 
    { 
		LED8=!LED8; 
 
		OSTimeDlyHMSM(0,0,4,500); 
    }     
} 
*/