Syntax Error Orti; CCTRL Tricore; CYCLETIME/ALARMTIME

Forum related to ERIKA Enterprise and RT-Druid version 2

Moderator: paolo.gai

Post Reply
felix.martin
Newbie
Posts: 4
Joined: Tue Apr 01, 2014 9:31 am

Syntax Error Orti; CCTRL Tricore; CYCLETIME/ALARMTIME

Post by felix.martin » Mon Jun 23, 2014 11:57 am

Hello everyone!

Since this is my first post I want to start with a little introduction. My name is Felix Martin and I am working as a research student for Timing Architects in Germany. My tasks are C++ development and maintaining our trace hardware (iC5000/iC6000). In order to test the trace hardware I am using Erika Enterprise running on a Infineon Aurix (TriCore) controller. Thank you very much for providing Erika Operating System and for the good documentation, which makes it nice to work with it.

I have two minor questions. (I am using the RT-Druid Release from May 30th running on windows 7 64-bit)

1. WinIDEA has problems to import the *.orti file created by RT-Druid. This is because of a trailing comma in the TASK section. See the following code listing.

Code: Select all

    TASK {
        ENUM "int" [
            "Not Running (0)" = 0,
            "0x1" = 0x1,
            "0x2" = 0x2,
            "0x4" = 0x4
        ] PRIORITY , "Actual Prio";
        ENUM "unsigned char" [
            "RUNNING"=0,
            "WAITING"=1,
            "READY"=2,
            "SUSPENDED"=3
        ] STATE, "Task State";
        ENUM "unsigned int" [
            "Stack0" : Stack0 = 0,
            "Stack1" : Stack1 = 1,
            "Stack2" : Stack2 = 2,
            "Stack3" : Stack3 = 3, // Trailing comma should not be here according to orti spec?
        ] STACK, "Task Stack";
        CTYPE "int" CURRENTACTIVATIONS, "Current activations";
    }, "Tasks";
Event though this is just a minor issue I wanted to make you aware of it. I am not totally sure if the spec may allow this syntax [1, 2, 3,] so it would be nice to tell me your opinion. If you think it is valid I will report to iSYSTEM that they have to make their parser more tolerant.

2. My second problem is that I don't know how to access the Counter Control Register of the TriCore. What I want to do is to write into CCTRL Counter Control Register in order to start the CPU Clock Counter as well as the Instruction Counter and then read the counts from the corresponding registers. The following snippet shows what I want to do.

Code: Select all

CCTRL = 0x02; // set Count Enable bit
myTestFunction(); // execute function about which I want to know how many instruction it taks
EE_UINT32 instructionCount = ICNT; // read current value from instruction count register
With this code I get the error that he CCTRL and ICNT are undeclared. I cannot figure out how to access the registers in the correct way. I don't expect you to present me the correct solution, but any hint to a useful resource would be very much appreciated.

Notes:
* I am using Hightec Compiler 4.6.4.0
* Documentation about the registers can be found on page 179/225 of tc16_archictecture_vol1.pdf

3. Why can cycletime not be set to zero? [question add by edit]
I do not understand why cycletime is not allowed to have a value of zero. Let's assume I want to start a task a certain period after start up, wouldn't it be reasonable to set alarmtime to the desired period and cycletime to zero in order to get the demanded result?

So those are my questions for now. Thanks for your attention.

Greets Felix

e.guidieri
Full Member
Posts: 166
Joined: Tue May 10, 2011 2:05 pm

Re: Syntax Error Orti; CCTRL Tricore; CYCLETIME/ALARMTIME

Post by e.guidieri » Mon Jun 23, 2014 3:25 pm

Hi felix,

quick answers
felix.martin wrote: 1. WinIDEA has problems to import the *.orti file created by RT-Druid. This is because of a trailing comma in the TASK section. See the following code listing.
...
I think you are right about this, the file work with Lauterbach tool probably relying to an extension of the standard. I will ask to the guy that implement RT-Druid.
felix.martin wrote: 2. My second problem is that I don't know how to access the Counter Control Register of the TriCore. What I want to do is to write into CCTRL Counter Control Register in order to start the CPU Clock Counter as well as the Instruction Counter and then read the counts from the corresponding registers. The following snippet shows what I want to do.

Code: Select all

CCTRL = 0x02; // set Count Enable bit
myTestFunction(); // execute function about which I want to know how many instruction it taks
EE_UINT32 instructionCount = ICNT; // read current value from instruction count register
CCTRL is a csfr (Core special function register), so you should not access it as memory mapped register (even tough AURIX will let you do that [but I don't know Ifx (Infineon registers file) related data struct, so you should check Ifx registers files by yourself, to do this]), expecially in this case that you are using this "tool" (I call it tool, to stress the fact that it's not a peripheral, but a core utility) for measurement.

With ERIKA you can use the following internal functions (You can find them in $ERIKA_FILES/pkg/cpu/tricore/inc/ee_tc_cpu.h):

Code: Select all

/* Start performance counter [CCNT] in normal mode */
__INLINE__ void __ALWAYS_INLINE__ EE_tc_start_CCNT( void );

/* Reads the CPU Clock Cycle Counter (includes overflow bit) */
__INLINE__  EE_UREG __ALWAYS_INLINE__ EE_tc_get_CCNT( void );
So your code will be:

Code: Select all

EE_tc_start_CCNT( ) // set Count Enable bit
myTestFunction(); // execute function about which I want to know how many instruction it taks
EE_UINT32 instructionCount = EE_tc_get_CCNT(); // read current value from instruction count register
In general to access a csfr you can use _mtcr _mfcr (defined inside Hightec <machine/intrinsics.h> file ) or ERIKA wrappers EE_tc_set_csfr(reg_id, reg) EE_tc_get_csfr(reg_id) that are valid for Hightec/Diab & Tasking compilers.

3. Why can cycletime not be set to zero? [question add by edit]
I do not understand why cycletime is not allowed to have a value of zero. Let's assume I want to start a task a certain period after start up, wouldn't it be reasonable to set alarmtime to the desired period and cycletime to zero in order to get the demanded result?
SetRelAlarm and SetAbsAlarm API behave exactly as you expect if you call them in code. Indeed (I just checked) autostarting ALARMS (configured in OIL file) cannot be configurated with CYCLETIME to 0 (for no reason for my point of view), I will check with the RT-Druid guy the reason of this behaviour.

Regards,
Errico Guidieri

felix.martin
Newbie
Posts: 4
Joined: Tue Apr 01, 2014 9:31 am

Re: Syntax Error Orti; CCTRL Tricore; CYCLETIME/ALARMTIME

Post by felix.martin » Wed Jun 25, 2014 1:21 pm

Hi Errico,

Thank you very much for your answers.
e.guidieri wrote: So your code will be:

Code: Select all

EE_tc_start_CCNT( ) // set Count Enable bit
myTestFunction(); // execute function about which I want to know how many instruction it taks
EE_UINT32 instructionCount = EE_tc_get_CCNT(); // read current value from instruction count register
In general to access a csfr you can use _mtcr _mfcr (defined inside Hightec <machine/intrinsics.h> file ) or ERIKA wrappers EE_tc_set_csfr(reg_id, reg) EE_tc_get_csfr(reg_id) that are valid for Hightec/Diab & Tasking compilers.
Very helpful, thanks.
e.guidieri wrote: SetRelAlarm and SetAbsAlarm API behave exactly as you expect if you call them in code. Indeed (I just checked) autostarting ALARMS (configured in OIL file) cannot be configurated with CYCLETIME to 0 (for no reason for my point of view), I will check with the RT-Druid guy the reason of this behaviour.
You are right, I was referring to OIL file, forgot to mention that.

So thanks again for your help, you will probably hear from me again, sooner or later.

Greets Felix

paolo.gai
Administrator
Posts: 875
Joined: Thu Dec 07, 2006 12:11 pm

Re: Syntax Error Orti; CCTRL Tricore; CYCLETIME/ALARMTIME

Post by paolo.gai » Wed Jun 25, 2014 3:02 pm

Hi Felix,

Just note the cycletime and the comma bugs have been solved and committed in the repository. They will be out in the next days in the nightly builds...

Regards,

Paolo

Post Reply