problem with Event and Extended task in OSEK with HC08 controller

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

problem with Event and Extended task in OSEK with HC08 controller

2,247 Views
nitinb
Contributor I

Hello All,

    I am new to OSEK and had just started to use it. I am using OSEK on HC908GZ16 micro, with target as HC08GZ60. I am having a problem with Event and Extended task. I am using the sample program from manual. The sample program has 3 task , Task A, B and C. Task A and C are autostarted. And Task B is started by taskA. The Event is set on Alarm which starts the Task C. The problem I am having is that the StartOS function is not able to start any Tasks. If I put breakpoint inside TaskA or TaskC it never reaches this point, instead it breaks inside StartOS() function. I suppose the OS is not able to start any task.

Any ideas what the problem might be and how I can resolve it.

 

Thanks in advance.

Nitin

Labels (1)
0 Kudos
Reply
3 Replies

834 Views
J2MEJediMaster
Specialist I

When you build OSEK, does the OSEKBuilder run and generate its resource files without an error? OSEKBuilder is responsible for generating the header and configuration files used to build OSEK. If it doesn't run properly, you get a mangled OSEK image. Another thing to check is the preprocessor output to ensure that the task data structures (as generated by OSEKBuilder) are present. It's possible that OSEK is being built without generating the tasks. Again, this would be an OSEKBuilder problem. What does your osdef.oil file look like?

 

---Tom

0 Kudos
Reply

834 Views
nitinb
Contributor I

Thanks Tom,

   The OSEKBuilder is not giving any error. I am listing the oil file generated below for your reference

 

---- Oil file ---

OIL_VERSION = "2.3";
#include "E:\metrowerks\osek\ost08\bin\ost2208.oil"

CPU cpu {

    APPMODE Mode;

    OS os1 {
        STATUS = EXTENDED;
        TargetMCU = HC08GZ60{
            SysTimer = HWCOUNTER {
                COUNTER = TaskCounter;
                Period = 1000 : "1 usec";
                TimerHardware = TIM1OC1 {
                    Prescaler = OS;
                };
            };
        };
        STARTUPHOOK = FALSE;
        SHUTDOWNHOOK = FALSE;
        ERRORHOOK = FALSE;
        PRETASKHOOK = FALSE;
        POSTTASKHOOK = FALSE;
        USEGETSERVICEID = FALSE;
        USEPARAMETERACCESS = FALSE;
        IsrStackSize = 64 : "64 bytes";
        CC = ECC1;
        DEBUG_LEVEL = 2;
    };

    TASK TaskA {
        PRIORITY = 2;
        SCHEDULE = FULL;
        AUTOSTART = TRUE{
            APPMODE = Mode;
        };
        ACTIVATION = 1;
    };

    TASK TaskB {
        PRIORITY = 1;
        SCHEDULE = FULL;
        AUTOSTART = FALSE;
        ACTIVATION = 1;
    };

    COUNTER TaskCounter{
        MINCYCLE = 0;
        MAXALLOWEDVALUE = 0xffff;
        TICKSPERBASE = 10 ;
    };

    ALARM AL1{
        COUNTER = TaskCounter;
        ACTION = SETEVENT {
            TASK = TaskC;
            EVENT = Cycle;
        };
        AUTOSTART = FALSE;
        CYCLIC = FALSE;
    };

    TASK TaskC {
        PRIORITY = 3;
        SCHEDULE = FULL;
        AUTOSTART = TRUE{
            APPMODE = Mode;
        };
        ACTIVATION = 1;
        STACKSIZE = 64 : "64 bytes";
        EVENT = Cycle;
    };

    EVENT Cycle{
        MASK = 1;
    };
};
---End of File --

 

I guess this is okay. Please let me know if you find any problems with this.

 

I guess the problem might be with my linker file(.prm file). Earlier while doing alarm example(BCC), I had similar problem and to get over it I had to include vector address defination of OSISRSystemTimer in .prm file.

I am including the linker file details below.

 

---Linker file ----

//This is a linker parameter file for the GZ16

NAMES END // CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too.

SEGMENTS // Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below.
    ROM                      =  READ_ONLY    0xC000 TO 0xFDFF;
    Z_RAM                    =  READ_WRITE   0x0040 TO 0x00FF;
    RAM                      =  READ_WRITE   0x0100 TO 0x043F;
END

PLACEMENT // Here all predefined and user segments are placed into the SEGMENTS defined above.
    DEFAULT_RAM                         INTO  RAM;
    DEFAULT_ROM, ROM_VAR, STRINGS       INTO  ROM; //  In case you want to use  as well, be sure the option -OnB=b is passed to the compiler.
    _DATA_ZEROPAGE, MY_ZEROPAGE         INTO  Z_RAM;
   
END


STACKSIZE 0x50

VECTOR 0 _Startup // Reset vector: this is the default entry point for an application.

// Added by nitin
VECTOR ADDRESS 0xFFF4 OSISRSystemTimer
VECTOR ADDRESS 0xFFFC OSTaskForceDispatchHandler    // needed for OSECC1

------End------ 

 

There might be problems with vectors and also with memory SEGMENTS

 

Any idea what might be going wrong?

 

Thanks

Nitin

0 Kudos
Reply

834 Views
J2MEJediMaster
Specialist I

Unfortunately, my experience with OSEK was on a HCS12DP512. However, there are enough similarities in the tool syntax that I will try to answer.

 

First, and foremost, if you are using any sort of custom interrupt handlers, you want to increase your stack size, if you have the RAM for that.

 

Second, you'll want to declare the handlers in the vector table file, vectors.c, and not in the .prm file. The easiest way to explain this is to show the .prm file. The interrupt vector table stuff is at the end of this file. Also recall that this is for a HC12S, so there's going to be a lot of memory page declarations. The stacksize increase is there, too.

 

 

/* This is a linker parameter file for the MC9S12XDP512 */

/* Note: this prm file does support the XGATE if all lines starting with */
/* ..NoXGATE are commented out or it does not support it if the lines with */
/* ..WithXGATE are commented out. However just one of the two cases must be active. */

NAMES END /* CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too. */

SEGMENTS /* here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */
              /* Register space  */
              /* IO_SEG      = PAGED            0x0000 TO   0x07FF; */

              /* nonpaged RAM */
/*NoXGATE*/   RAM             = READ_WRITE      0x2000 TO   0x3EFF;
              OSNEARRAM       = READ_WRITE      0x3F00 TO   0x3FFF;  /* direct page is placed here */
//WithXGATE   RAM             = READ_WRITE      0x2000 TO   0x3FFF ALIGN 2;
              /* when changing the RAM_XGATE range, please check the Startup.cmd */

              /* nonpaged EEPROM */
              EEPROM          = READ_ONLY       0x0C00 TO   0x0FFF;

              /* paged EEPROM */
              EEPROM_FC       = READ_ONLY     0xFC0800 TO 0xFC0BFF;
              EEPROM_FD       = READ_ONLY     0xFD0800 TO 0xFD0BFF;
              EEPROM_FE       = READ_ONLY     0xFE0800 TO 0xFE0BFF;
/*            EEPROM_FF       = READ_ONLY     0xFF0800 TO 0xFF0BFF; intentionally not defined: equivalent to RAM */

              /* paged RAM */
/*NoXGATE*/   RAM_FB          = READ_WRITE    0xFB1000 TO 0xFB1FFF;
/*NoXGATE*/   RAM_FC          = READ_WRITE    0xFC1000 TO 0xFC1FFF;
              RAM_FD          = READ_WRITE    0xFD1000 TO 0xFD1FFF;
/*            RAM_FE          = READ_WRITE    0xFE1000 TO 0xFE1FFF; intentionally not defined: equivalent to RAM */
/*            RAM_FF          = READ_WRITE    0xFF1000 TO 0xFF1FFF; intentionally not defined: equivalent to RAM */

              /* unbanked FLASH */
              ROM_4000        = READ_ONLY       0x4000 TO   0x7FFF;
                  
              ROM_C000        = READ_ONLY       0xC000 TO   0xFEFF;
              ROM_FF10        = READ_ONLY       0xFF10 TO   0xFFFF; /* for vector table */

              /* paged FLASH */
              PAGE_E0         = READ_ONLY     0xE08000 TO 0xE0BFFF;
              PAGE_E1         = READ_ONLY     0xE18000 TO 0xE1BFFF;
              PAGE_E2         = READ_ONLY     0xE28000 TO 0xE2BFFF;
              PAGE_E3         = READ_ONLY     0xE38000 TO 0xE3BFFF;
              PAGE_E4         = READ_ONLY     0xE48000 TO 0xE4BFFF;
              PAGE_E5         = READ_ONLY     0xE58000 TO 0xE5BFFF;
              PAGE_E6         = READ_ONLY     0xE68000 TO 0xE6BFFF;
              PAGE_E7         = READ_ONLY     0xE78000 TO 0xE7BFFF;
              PAGE_E8         = READ_ONLY     0xE88000 TO 0xE8BFFF;
              PAGE_E9         = READ_ONLY     0xE98000 TO 0xE9BFFF;
              PAGE_EA         = READ_ONLY     0xEA8000 TO 0xEABFFF;
              PAGE_EB         = READ_ONLY     0xEB8000 TO 0xEBBFFF;
              PAGE_EC         = READ_ONLY     0xEC8000 TO 0xECBFFF;
              PAGE_ED         = READ_ONLY     0xED8000 TO 0xEDBFFF;
              PAGE_EE         = READ_ONLY     0xEE8000 TO 0xEEBFFF;
              PAGE_EF         = READ_ONLY     0xEF8000 TO 0xEFBFFF;
              PAGE_F0         = READ_ONLY     0xF08000 TO 0xF0BFFF;
              PAGE_F1         = READ_ONLY     0xF18000 TO 0xF1BFFF;
              PAGE_F2         = READ_ONLY     0xF28000 TO 0xF2BFFF;
              PAGE_F3         = READ_ONLY     0xF38000 TO 0xF3BFFF;
              PAGE_F4         = READ_ONLY     0xF48000 TO 0xF4BFFF;
              PAGE_F5         = READ_ONLY     0xF58000 TO 0xF5BFFF;
              PAGE_F6         = READ_ONLY     0xF68000 TO 0xF6BFFF;
              PAGE_F7         = READ_ONLY     0xF78000 TO 0xF7BFFF;
              PAGE_F8         = READ_ONLY     0xF88000 TO 0xF8BFFF;
              PAGE_F9         = READ_ONLY     0xF98000 TO 0xF9BFFF;
              PAGE_FA         = READ_ONLY     0xFA8000 TO 0xFABFFF;
              PAGE_FB         = READ_ONLY     0xFB8000 TO 0xFBBFFF;
              PAGE_FC         = READ_ONLY     0xFC8000 TO 0xFCBFFF;
/*            PAGE_FD         = READ_ONLY     0xFD8000 TO 0xFDBFFF; intentionally not defined: equivalent to ROM_4000 */

/*NoXGATE*/   PAGE_FE         = READ_ONLY     0xFE8000 TO 0xFEBFFF;

      /*      PAGE_FF         = READ_ONLY     0xFF8000 TO 0xFFBFFF; intentionally not defined: equivalent to ROM_C000 */
END

PLACEMENT /* here all predefined and user segments are placed into the SEGMENTS defined above. */
              _PRESTART,                   /* Used in HIWARE format: jump to _Startup at the code start */
              STARTUP,                     /* startup data structures */
              ROM_VAR,                     /* constant variables */
              STRINGS,                     /* string literals */
              NON_BANKED                   /* runtime routines which must not be banked */
                                           /* in case you want to use ROM_4000 here as well, make sure
                                              that all files (incl. library files) are compiled with the
                                              option: -OnB=b */
                                   INTO  ROM_C000;
              .ostext              INTO  ROM_4000;
              .bank0               INTO  PAGE_E0; /* Task code from main.c */
              DEFAULT_ROM          INTO  PAGE_E1, PAGE_E2, PAGE_E3, PAGE_E4, PAGE_E5, PAGE_E6, PAGE_E7,
                                         PAGE_E8, PAGE_E9, PAGE_EA, PAGE_EB, PAGE_EC, PAGE_ED, PAGE_EE, PAGE_EF,
                                         PAGE_F0, PAGE_F1, PAGE_F2, PAGE_F3, PAGE_F4, PAGE_F5, PAGE_F6, PAGE_F7,
                                         PAGE_F8, PAGE_F9, PAGE_FA, PAGE_FB, PAGE_FC, PAGE_FE;

              OSZeroPage           INTO  OSNEARRAM;

              DEFAULT_RAM,                       /* all variables, the default RAM location */
              .stackstart,
              .stack,
              .stackend            INTO  RAM;
             
/*NoXGATE*/   PAGED_RAM            INTO  RAM_FB, RAM_FC, RAM_FD;

             .vectors              INTO  ROM_FF10;
END
ENTRIES                                     /* switch off smart linking to get unreferenced vector table */
_vectab
OsBuildNumber
_OsOrtiStackStart
_OsOrtiStart
END

STACKSIZE 0x100

 Here is my .oil file. Note that it is OIL version 2.5. I think there are some syntax differences between it and 2.3, so be careful in using this. Note that for my timer (which was in software), that an interrupt priority is declared, but this might be version 2.5 requirement. Note also that I declare my interrupt handler in here. I hope this helps.

 

/*
 * OSEK implementation file (OIL file)
 */

OIL_VERSION = "2.5";

#include "C:\Program Files\Freescale\CW for HC12 V4.5\OSEK\osts12x\bin\ost22s12x.oin"

CPU cpu1 {

    OS os1 {
        CC = AUTO;
        TargetMCU = S12XDP512 {
            HCBasePage = FALSE;
            HCBankCode = TRUE;
            SysTimer = SWCOUNTER {
                COUNTER = SYSTEMTIMER;
                ISRPRIORITY = 2;
                TimerHardware = TIMOC1 {
                    Prescaler = OS {
                        Value = 4;
                    };
                    TimerModuloValue = 0x3000;
                };
            };
        };
        STATUS = EXTENDED;
        DEBUG_LEVEL = 2;
        STARTUPHOOK = FALSE;
        ERRORHOOK = FALSE;
        SHUTDOWNHOOK = FALSE;
        PRETASKHOOK = FALSE;
        POSTTASKHOOK = FALSE;
        USEGETSERVICEID = FALSE;
        USEPARAMETERACCESS = FALSE;
        IsrStackSize = 64;
    };

    COUNTER SYSTEMTIMER {
        MAXALLOWEDVALUE = 0xffff;
        TICKSPERBASE = 1;
        MINCYCLE = 0;
    };
    TASK InitTask {
        SCHEDULE = FULL;
        AUTOSTART = TRUE;
        ACTIVATION = 1;
        PRIORITY = 5;
    };
    TASK InputTask {
        SCHEDULE = FULL;
        AUTOSTART = FALSE;
        ACTIVATION = 1;
        PRIORITY = 0;
        EVENT = DOWN_EVENT;
        STACKSIZE = 100;
        EVENT = UP_EVENT;
    };
    ALARM CyclicAlarm {
        COUNTER = SYSTEMTIMER;
        ACTION = ACTIVATETASK {
            TASK = InputTask;
        };
        AUTOSTART = FALSE;
    };

    APPMODE Mode;

    TASK SwitchEventTask{
        PRIORITY = 10;
        EVENT = DOWN_EVENT;
        EVENT = UP_EVENT;
        AUTOSTART = FALSE;
        SCHEDULE = FULL;
        ACTIVATION = 1;
        STACKSIZE = 100;
    };

    EVENT DOWN_EVENT{
        MASK = AUTO : "Switch depressed";
    };

    EVENT UP_EVENT{
        MASK = AUTO : "Switch released";
    };

    ISR SW2_Isr {
        CATEGORY = 1;
        PRIORITY = 7;
        VectorOffset = 0x8e;
    };

};

 

 

 

 

 

 

 

0 Kudos
Reply