RTX166: Starting a new Project
Information in this article applies to:
- C166 Version 4.03
- RTX166 Version 3.10a
QUESTION
How 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?
ANSWER
Creating a new RTX166 program is relatively 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
- Create a subdirectory for your RTX166 project.
- In µVision2, create a new project in that directory.
-
Once the project is created, select Select
Device... from the Project menu. This
displays the device database dialog.
-
Select one of the Infineon C166 derivatives or one of the
STMicroelectronics ST10 derivatives. If you're unsure what to
choose, select the Infineon C167CR-LM and click OK.
-
Select Options for Target... from the
Project menu. This displays the project options
for the compiler, assembler, linker, and so on.
-
Under the Target tab, select the RTX-166 Full
Real-Time OS as the Operating System.
-
Under the Target tab, in the External Memory
section, for #1, select ROM starting at 0x000000 for size of
0x8000. For #2, select RAM starting at 0x008000 for a size of
0x8000.
RTX166 Configuration Files
-
Copy the following files from the \keil\c166\rtx166 directory
to your new project directory: RTXCONF.C66 and RTXSETUP.H.
-
Edit the RTXSETUP.H file to configure the OS as desired. You
can leave this file alone for this example. As you become more
familiar with the OS, the items in this config file will make more
sense.
-
Add the RTXCONF.C66 file to the project. You may wish to create
a new filegroup for this file.
-
When you add the RTXCONF.C66 file, µVision2 will prompt you to
select the file type for this file. Select C Source File from the
drop-down menu and µVision2 add this file to your project.
-
The RTXCONF.C66 file is special. It must be compiled with the
SRC option and then assembled with the A166 assembler to create an
OBJ file.
-
Right-click on the RTXCONF.C66 file. This opens the local menu.
Select Options for File.... The option dialog
displays.
-
Under the Properties tab, check the Generate
Assembler Source File and the Assemble SRC File checkboxes. Note
that when you view the dialog, these options may have grey checks
in the checkboxes. A grey check means that the options of the
previous file group or target will be used. The checks must be
black to be "checked".
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 Program
Create a new, empty file and insert the following source code.
#include
#include
/*-----------------------------------------------
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 ALSO
Last Reviewed: Thursday, February 25, 2021