Spanish Italian
17436 Users    

How to Configure the EDF Scheduler

  Download PDF version of the Article

When configuring the EDF kernel for an Erika Enterprise application, the user has the possibility to specify the tick length in the OIL file to allow the specification of a relative deadline using a temporal value. In particular, the user can specify a tick value as follows:

KERNEL_TYPE = EDF { TICK_TIME = "25 ns ";};
and then specify a relative deadline using a timing value as follows
TASK myTask1 {
REL_DEADLINE = "10 ms ";
};

The RT-Druid code generator will handle the the conversion between the relative deadline value in the corresponding timing value automatically. The important thing in this process is to correctly specify the TICK_TIME. In general, that value depends on the timing reference which is made available by the dsPIC (R) DSC. The current timing reference implemented in the EDF kernel is based on the value
of a 32 bit timer. Having a 32 bit timing reference helps implementing a long lifetime for the circular timer, allowing the support of relatively long relative deadlines. The 32 bit timer is obtained by concatenating the two 16 bit timers TMR8 and TMR9 available on the dsPIC (R) DSC. The clock used for the timers is the system clock, with a tick time equal to 1 Fcy, where Fcy = Fosc2 . Fosc, the frequency of the oscillator, depends on its configuration which is typically done in the application by using appropriate macros shown below.

The following paragraphs describe two typical oscillator values which can be used, and the correspondent parameters which has to be put in the OIL file. The same settings are available in two template applications distributed with Erika Enterprise which work on the FLEX boards featuring a dsPIC (R) DSC model PIC33FJ256MC710. Finally, always remember that the EE_time_init function has to be called inside the main function before using any primitive of the EDF kernel.

1 Primary oscillator without PLL
In this configuration, a primary oscillator at 4 MHz is used without any moltiplication. In this case, the tick duration is 500 ns, and the dsPIC (R) DSC is running at 2 MIPS. To configure the system in this way, the C language has to contain the following compiler directive:

_FOSCSEL ( FNOSC_PRI);
The OIL file will contain the following line:
KERNEL_TYPE = EDF { TICK_TIME = "500 ns ";};

The maximum relative deadline which can be expressed in the OIL file is 500ns 231, which is slightly more than 1073 secs. A template application which initializes an EDF periodic task for this case is available under the RT-Druid templates.

2 Primary oscillator with PLL
In this configuration, the dsPIC (R) DSC is configured to provide its maximum computational power. To do that, the internal PLL is used to push the internal frequency Fosc to 80 MHz. As a consequence, Fcy become 40 MHz, which is the nominal maximum computational power of 40 MIPS declared by Microchip. In this case, the tick duration is 25 ns.
To configure the system in this way, the C language has to contain the following compiler directive:

_FOSCSEL ( FNOSC_PRIPLL);

Moreover, at the beginning of the main function, the PLL multiplier registers needs to be set with the following code:

/* Clock setup for 40 MIPS */
CLKDIVbits. DOZEN = 0;
CLKDIVbits. PLLPRE = 0;
CLKDIVbits. PLLPOST = 0;
PLLFBDbits. PLLDIV = 78;
/* Wait for PLL to lock */
while( OSCCONbits. LOCK !=1);

Finally, the OIL file will contain the following line:

KERNEL_TYPE = EDF { TICK_TIME = "25 ns ";};

The maximum relative deadline which can be expressed in the OIL file is 25ns 231, which is slightly more than 53 secs.

3 EE_time_init
Synopsis
void EE_time_init(void);

Description
The function programs TMR8 and TMR9 as a 32 bit timer which is then used by the EDF Kernel to take the timing reference. The function must be called before calling any Erika Enterprise primitive.

See also:
http://dev.emcelettronica.com/erika-enterprise
http://dev.emcelettronica.com/writing-software-dspic-r-dsc-using-erika-e...
http://dev.emcelettronica.com/how-does-erika-enterprise-support-flex-boa...

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
1 + 8 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Who's new

  • pulper
  • mauriss
  • jbares
  • christiank79
  • agabor
  • fabriziopd
  • irenix
  • pepershoe
  • raghun14
  • andreaspousette

Who's online

There are currently 0 users and 27 guests online.