| |||||
Technical Support Support Resources
Product Information | RTX166: STARTING A NEW PROJECTInformation in this article applies to:
QUESTIONHow do I get started with RTX166 and C166 Version 4? I have installed µVision2 and the C166 compiler as well as RTX166. How do I create a simple example program? ANSWERCreating a new RTX166 program is fairly simple. However, there are a lot of steps you must follow. You must create a new project and set some project options, copy some configuration files from the RTX166 directory, and create a complete sample program. Creating a Project
RTX166 Configuration Files
At this point, you may wish to test what you have done. Right-click on RTXCONF.C66 and select Translate RTXCONF.C66 from the local menu. The Build Window (at the bottom of the screen) will show the following: compiling Rtxconf.c66... assembling Rtxconf.src... Rtxconf.src - 0 Error(s), 0 Warning(s). If the above information does not appear there is a problem. Check the steps above to make sure the files were added correctly and that the project was configured properly. Example ProgramCreate a new, empty file and insert the following source code.
#include <rtx166.h>
#include <reg167.h>
/*-----------------------------------------------
If the memory model is TINY or SMALL, create an
8K system heap.
If the memory model is larger, create a 4K system
heap and a 4K context heap.
-----------------------------------------------*/
#if __MODEL__ <= 1
static unsigned char near system_heap [0x2000];
#else
static unsigned char huge system_heap [0x1000];
static unsigned char near context_heap [0x1000];
#endif
/*-----------------------------------------------
Configuration data for RTX166.
-----------------------------------------------*/
#define WSP 256 /* workspace (in bytes) for each task */
static t_rtx_config rtx_cfg_data =
{
8, /* max tasks */
8, /* max mailboxes */
8, /* max semaphores */
8, /* max memory pools */
WSP, /* idle task workspace (in bytes) */
WSP, /* clock task workspace (in bytes) */
FALSE, /* round_robin */
system_heap, /* system_pool */
sizeof (system_heap), /* system_pool_size */
FALSE, /* rtx51 */
#if __MODEL__ > 1
context_heap, /* context_pool */
sizeof (context_heap), /* context_pool_size */
#endif
};
/*-----------------------------------------------
RTX166 manifest constants and handles for the
blinker and flasher tasks.
-----------------------------------------------*/
#define FLASHER_TASK 1 /* Task number for the FLASHER task */
#define BLINKER_TASK 2 /* Task number for the BLINKER task */
t_rtx_handle blinker_task;
t_rtx_handle flasher_task;
/*-----------------------------------------------------------------------------
-----------------------------------------------------------------------------*/
static void blinker (void) _task_ BLINKER_TASK
{
os_set_interval (blinker_task, 100);
while (1)
{
P7 ^= 0x80;
os_wait_interval ();
}
}
/*-----------------------------------------------------------------------------
-----------------------------------------------------------------------------*/
static void flasher (void) _task_ FLASHER_TASK
{
os_set_interval (flasher_task, 10);
while (1)
{
P7 ^= 0x01;
os_wait_interval ();
}
}
/*-----------------------------------------------------------------------------
-----------------------------------------------------------------------------*/
void main (void)
{
DP7 = 0xFF;
ODP7 = 0xFF;
/*-----------------------------------------------
Start the multitasker.
-----------------------------------------------*/
os_start_system (&rtx_cfg_data);
/*-----------------------------------------------
Create tasks.
-----------------------------------------------*/
os_create_task (&blinker_task, BLINKER_TASK, WSP);
os_create_task (&flasher_task, FLASHER_TASK, WSP);
/*-----------------------------------------------
Begin looping. Then, kill this task. If it
doesn't die, try again.
-----------------------------------------------*/
for (;;)
{
os_delete_task (os_running_task_id ());
}
}
Save this file as MAIN.C and add it to the project. Your project is now complete. You should be able to compile and link with no errors. When you run this program in the simulator, be sure to watch port 7. You will see bit 0 toggling very quickly while bit 7 toggles very slowly. SEE ALSOLast Reviewed: Thursday, November 17, 2005 | ||||
| |||||