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

📄 main.c

📁 nec平台下的ucos版本
💻 C
字号:
/*
*******************************************************************************
**
**  This device driver was created by Applilet for the 78K0/KB2, 78K0/KC2,
**  78K0/KD2, 78K0/KE2 and 78K0/KF2 8-Bit Single-Chip Microcontrollers.
**
**  Copyright(C) NEC Electronics Corporation 2002 - 2005
**  All rights reserved by NEC Electronics Corporation.
**
**  This program should be used on your own responsibility.
**  NEC Electronics Corporation assumes no responsibility for any losses
**  incurred by customers or third parties arising from the use of this file.
**
**  Filename : main.c
**  Abstract : This file implements main function
**  APIlib:  NEC78K0KX2.lib V1.01 [09 Aug. 2005]
**
**  Device :	uPD78F0547
**
**  Compiler:  NEC/CC78K0
**
*******************************************************************************
*/
/*
*******************************************************************************
**  Include files
*******************************************************************************
*/
#pragma	DI
#pragma	EI
#pragma	SFR
#pragma NOP
#pragma STOP
#pragma HALT

#include "includes.h"

#define TASK_STK_SIZE 32

OS_STK Task3Stk[TASK_STK_SIZE];
OS_STK Task4Stk[TASK_STK_SIZE];


//OS_STK TaskStack[100];
//unsigned char a,b,c;
INT16U m,n;
	
void task3(void* pdata);
void task4(void* pdata);

//void mycallback(void *ptmr, void *callback_arg);

void halWait(INT16U timeout) ;
//void ledFlash(INT16U cycles, INT16U period) ;
/*
*******************************************************************************
**  MacroDefine
*******************************************************************************
*/
/*
**-----------------------------------------------------------------------------
**
**  Abstract:
**	main function
**
**  Parameters:
**	None
**
**  Returns:
**	None
**
**-----------------------------------------------------------------------------
*/


void halWait(INT16U timeout) {

    // This sequence uses exactly 8 clock cycle for each round
    do {
        NOP();
        NOP();
        NOP();
        NOP();
    } while (--timeout);

}
/*
void ledFlash(INT16U cycles, INT16U period) {
	int i=0;
	
   	for ( i=0; i<cycles; i++) {
		
    	  P7.3=!P7.3;
		  
    	if (period>0)
    	    halWait(period);
    }
}
*/
/*
void task1(void* pdata)
{  
   TM00_Start();
   while(1)
   {
     a++;
     OSTimeDly(3);
   }
}

void task2(void* pdata)
{
   OS_TMR *ptmr;
   INT8U   err;
   ptmr = OSTmrCreate(0,5,OS_TMR_OPT_PERIODIC,mycallback,(void *)0,"fun",&err);
   OSTmrStart(ptmr,&err);
   pdata = pdata;
   while(1)
   {
     b++;
     OSTmrSignal();
     OSTimeDly(3);
   }
    
}
*/
void task3(void* pdata)
{  

  TM00_Start();
  
   while(1){
   	

for (m=0;m<30; m++) {
		
    	  P7.3=!P7.3;
		  
    	    	    halWait(200*m);

}
 P7.3=1;


 // P7.3=!P7.3;

//ledFlash(10,  1000);

OSTimeDly(20);

  //OSTimeDlyHMSM(0, 0, 2, 0);

 // OSTaskDel(3);

   }
}

void task4(void* pdata)
{  

      while(1){
   	

for (m=0;m<30; m++) {
		
    	  P7.2=!P7.2;
		  
    	    	    halWait(200*m);

}
 P7.2=1;


 // P7.3=!P7.3;

//ledFlash(10,  1000);

OSTimeDly(20);
 
}
	  }
/*
void mycallback(void *ptmr, void *callback_arg)
{
    c++;
}
*/
void main(void)
{
   IMS = MEMORY_IMS_SET;
   IXS = MEMORY_IXS_SET;
  /* DI( );*/
   OSInit();
  
   //OSTaskCreate(task1,(void *)0,TaskStack+100,7);
   //OSTaskCreate(task2,(void *)0,TaskStack+50,8);

OSTaskCreate(task3, (void *)0, &Task3Stk[TASK_STK_SIZE-1], 3);
OSTaskCreate(task4, (void *)0, &Task4Stk[TASK_STK_SIZE-1], 4);
  
   OSStart();
}

⌨️ 快捷键说明

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