Discussion Forum

RTX166Tiny & EC++ have problem!

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
Oleg Trenkin
Posted
14-May-2007 06:47 GMT
Toolset
C166
New! RTX166Tiny & EC++ have problem!

Good day!

I have a problem with using RTX166 Tiny OS with EC++.
If I try to define tasks in .cpp file, I dont see JUMP to _main() function.

In technical support:
"RTX166 TINY: CAN'T DEFINE TASKS IN EC++"
http://www.keil.com/support/docs/2812.htm
advises to "Simply define your _task_ and interrupt functions in a .C file".
In this case Can I use C++ features (ex. define objects) in tasks functions?

In file C:\Program Files\Keil\C166\Rtx_Tiny\readme5.txt I have read following note:

Function os_start for EC++ compatiblity
=======================================
The function os_start enables the usage of RTX166 Tiny together with EC++. EC++
requires special initalizations that are performed in the main routine. After
this initalizations, the os_start function can be called to start the RTX166
Tiny kernel.


EXTERN_C void _main ()  {
  init_mempool (mempool, sizeof (mempool));  // create memory pool for new & delete
  __sti__init__ ();                          // call initializer functions
  os_start ();                               // start RTX166 kernel
}

But senselessly try to call os_start(), if _main() is not called.

P.S.
Problem "expected {" I resolve using replace _task_ with __task. Is it correct?

Read-Only
Author
Stephane Georget
Posted
14-May-2007 18:41 GMT
Toolset
C166
New! RE: RTX166Tiny & EC++ have problem!

Oleg,

I don't quite understand your problem, however there is one thing that strikes me in the code you posted: __sti_init__() does not return. Therefore your OS won't be initialized when you start using it (and I don't want to imagine what's going to happen then...)

__sti_init__() initializes all your objects, virtual tables or what-have-you, and then it calls main().

Therefore you should put os_init() in your main() function, not in _main().

After the OS is initialized, then you can start creating tasks.

You need to use the keyword __task instead of _task_ for tasks definitions in C++ files.

I've been using EC++ and RTX Tiny and ARTX for quite a while and it works pretty well.

.02

Steph-

Read-Only
Author
Stephane Georget
Posted
14-May-2007 18:53 GMT
Toolset
C166
New! RE: RTX166Tiny & EC++ have problem!

Ah, scratch that, __sti_init__() DOES return...

Steph-

Read-Only
Author
Oleg Trenkin
Posted
18-May-2007 13:17 GMT
Toolset
C166
New! RE: RTX166Tiny & EC++ have problem!

Stephane,

You said:

"Therefore you should put os_init() in your main() function, not in _main()"


but where is the main() function situated?

There is no main function in OS projects, only tasks!

Now, I've placed _main() CALL explicitly in task 0.
But I'm sure that it is not correct way, isn't it?

the problem remains.

Read-Only
Author
Stephane Georget
Posted
19-May-2007 02:05 GMT
Toolset
C166
New! RE: RTX166Tiny & EC++ have problem!

Oleg,

Ignore my previous post, as it is confusing.

Short answer: define a main() anyway, and see what happens.

Long answer:

There is an example in Keil\C166\Rtx_Tiny which is supposed to show how to use EC++ and RTX Tiny. It doesn't work on my machine! _main() is never called, I believe there is a problem with this example.

It seems that RTX Tiny defines a symbol called main, which in turn calls os_start() (look at the source code for RTX Tiny)

One workaround is to define, and it can by anywhere in your cpp code really:

int main() {}

This symbol will override the one in RTX Tiny's library, which means that this function will be called, rather than the one inside the real time library. Then, the EC++ parser will recognize this special function and call _main() automatically, as soon as main() is executed (look at how main() is modified inside the .ic. file)

Other workaround: modify the .a66 initialization file so it calls _main instead of main. Look for the lines of code that say:


...
EXTRN   main:Model
...

$IF TINY
                JMP     main
$ELSE
                JMP     FAR main
$ENDIF

and replace all main with _main.

Not sure if this makes sense, but I hope this helps...

-Stéphane

Read-Only
Author
Reinhard Keil
Posted
21-May-2007 13:04 GMT
Toolset
C166
New! RE: RTX166Tiny & EC++ have problem!

Take a look here: C:\Keil\C166\Examples\EC++\RtxTiny
This example shows you how to create an RtxTiny Application with EC++.

Reinhard

Read-Only
Author
Stephane Georget
Posted
21-May-2007 14:55 GMT
Toolset
C166
New! RE: RTX166Tiny & EC++ have problem!

Hello Reinhard,

This example seems to be broken (at least for me), that's the problem.

_main() is never called, which is an issue because then EC++ classes are not initialized, neither is the memory pool...

This example is so simple (no constructors, not even a single data member) that it appears to be working, whereas in fact the EC++ initialization is not done at all.

-Stephane

Next Thread | Thread List | Previous Thread Start a Thread | Settings