📄 main.c
字号:
#include <hidef.h> /* for EnableInterrupts macro */
#include "MC9S08AW60.h"
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "portable.h"
#define MY_PRIORITY1 ( tskIDLE_PRIORITY + 6 )
#define MY_PRIORITY2 ( tskIDLE_PRIORITY + 4 )
#define MY_PRIORITY3 ( tskIDLE_PRIORITY + 2 )
#define MY_PRIORITY4 ( tskIDLE_PRIORITY + 8 )
static void my_task1 ( void* pvParameters );
static void my_task2 ( void* pvParameters );
static void my_task3 ( void* pvParameters );
static void my_task4 ( void* pvParameters );
void MCU_Init(void);//系统时钟初始化
void main(void)
{
MCU_Init();//系统时钟初始化
EnableInterrupts; /* enable interrupts */
PTADD=0XFF;
PTAD=0X00;
/* include your code here */
xTaskCreate( my_task1, "task1", configMINIMAL_STACK_SIZE, NULL, MY_PRIORITY1, NULL );
xTaskCreate( my_task2, "task2", configMINIMAL_STACK_SIZE, NULL, MY_PRIORITY2, NULL );
xTaskCreate( my_task3, "task3", configMINIMAL_STACK_SIZE, NULL, MY_PRIORITY3, NULL );
xTaskCreate( my_task4, "task4", configMINIMAL_STACK_SIZE, NULL, MY_PRIORITY4, NULL );
vTaskStartScheduler();//开始任务调度
// __RESET_WATCHDOG(); /* feeds the dog */
}
//======================系统时钟初始化==================
void MCU_Init()
{
ICGC1=0X78; //使用外部4MHz晶振
ICGC2=0x30; //启动PLL倍频CPU=40MHz; 总线=20MHz
while(ICGS1_LOCK==0) {} ;//等待PLL稳定
SOPT_COPE=0;//关闭看门狗,若想使能看门狗删除该指令即可
}
//==================系统任务1=========================
static void my_task1 ( void* pvParameters )
{
int i;
for(;;)
{
i++;
PTAD_PTAD1=~PTAD_PTAD1;
vTaskDelay(200);
}
}
//==================系统任务2========================
static void my_task2 ( void* pvParameters )
{
int i;
for(;;)
{
i++;
PTAD_PTAD3=~PTAD_PTAD3;
vTaskDelay(500);
}
}
//==================系统任务3=========================
static void my_task3 ( void* pvParameters )
{int i;
for(;;)
{
// __RESET_WATCHDOG(); /* feeds the dog */
i++;
PTAD_PTAD5=~PTAD_PTAD5;
vTaskDelay(100);
}
}
//==================系统任务3=========================
static void my_task4 ( void* pvParameters )
{int i;
for(;;)
{
// __RESET_WATCHDOG(); /* feeds the dog */
i++;
PTAD_PTAD7=~PTAD_PTAD7;
vTaskDelay(1000);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -