02.01.2015 Views

CooCox CoOS User's Guide

CooCox CoOS User's Guide

CooCox CoOS User's Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

tasks,flags, mutexes,semaphores and so on. At last, system will start the first<br />

scheduling through CoStartOS() function. The code after CoStartOS() will not<br />

be implemented, since OS will not return after the first scheduling.<br />

Add the following code after the initialization in main function:<br />

CoInitOS (); /*!< Initial <strong>CooCox</strong> <strong>CoOS</strong> */<br />

/*!< Create three tasks */<br />

CoCreateTask (taskA,0,0,&taskA_stk[128-1],128);<br />

CoCreateTask (taskB,0,1,&taskB_stk[128-1],128);<br />

CoCreateTask (led ,0,2,&led_stk[128-1] ,128);<br />

CoStartOS(); /*!< Start multitask */<br />

1.2.5 Configure and clip <strong>CoOS</strong><br />

Open OsConfig.h, here contains all the items which can be configured and<br />

clipped. Be sure you have known all the functions of every item before you<br />

modify it, there are detailed notes to explain the function of every item in the<br />

document.<br />

First of all, we must configure a few of the items which must be checked or<br />

modified:<br />

CFG_MAX_USER_TASKS<br />

It implies the maximum tasks that users can create, we have only 3 tasks,<br />

so we modify it as 3 to save space.<br />

CFG_CPU_FREQ<br />

It is the system clock that your system used, SystemInit() initialized chip<br />

frequence as 72MHz before, so here we modify it as 72000000, corresponding<br />

to the operating frequence of the objective chip.<br />

CFG_SYSTICK_FREQ<br />

This is the system ticks period, we set it as 100 for 10ms,100Hz's system<br />

tick clock.<br />

Have done all the work, your program should run normally. Compile your<br />

project, you could see the phenomenons we described above after downloading<br />

the program to the hardware by our Colink emulator.<br />

8

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!