www.pudn.com > ucos port forf240.rar > mian.c, change:2003-11-18,size:1807b


/*This file can test OSIntCtrSw() and OSTickISR(),calling OSTimeDly() schedued to  
IdleTask,untile receive timer interrupt.timer int call OSTickISR(),then call OSTimeTick() 
decrease the value of counter-OSTCBDLY to 0.schedued to Testtask,led's value is changed*/ 
    
 #include "includes.h" 
 
 
OS_STK TestTaskStk[100]; 
OS_STK TaskStk[100]; 
 
void TestTask(void *pdata); 
void Task(void *pdata); 
 
void KickDog(void) 
{ 
     *WDKEY=0X0055; 
     *WDKEY=0X00AA; 
     *WDCR=0X006F; 
     return; 
}         
 
void HardwareInit(void) 
{ 
    asm(" clrc CNF"); 
    asm(" setc SXM"); 
    *IFR=0X0FFFF; 
    *IMR=0X0004;     /*enable Int2*/ 
     
    *CKCR1=0X00BB;   /*clock in is 10MHz,cpu clock is 20Mhz*/ 
    *CKCR0=0X00C1; 
    *SYSCR=0X40C0;  
    *WDCR=0X006F; 
    KickDog(); 
    return; 
}                   
 
 
void T2PInit(void) 
{ 
  *T2CNT=0X0000; 
  *T2PR=0X186A;     /*timer interrupt frequence is 100HZ*/ 
  *T2CON=0X0EC0A;   /*continuous up/down mode,TPS is 16 */ 
   
  *EVIFRB|=0X0001; 
  *EVIMRB=0X0001;    /*enable timer1 Period interrupt*/ 
  return; 
}  
void  nothing(void) 
{ 
  return; 
} 
 
 
void main(void) 
{  
  HardwareInit(); 
  T2PInit(); 
  OSInit();  
  printf("Inital End.\n"); 
  OSTaskCreate(TestTask,(void *)0,&TestTaskStk[0],4); 
   
  printf("MultiTask Start...\n"); 
  OSStart(); 
} 
  volatile int led=0; 
void TestTask(void *pdata) 
{ 
   
  pdata=pdata; 
  *T2CON|=0x0040; 
  OSTaskCreate(Task,(void *)0,&TaskStk[0],5); 
  asm(" clrc INTM");       /*Stack init cpu status reg disable interrupt*/        
  while(1) 
  {   
      led++; 
      printf("led=%d\n",led); 
      OSTimeDly(1); 
    
  } 
}  
void Task(void *pdata) 
{ 
   pdata=pdata; 
   asm("	clrc INTM"); 
   while(1) 
   { 
     printf("This is Task!\n"); 
     OSTimeDly(2); 
   } 
}