This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

runtime modification of vector table

Hello,

I'm using the C6747, CCS 4.2.3 and CSLr for register configuration. I'm NOT using BIOS.

Most of my ISR functions are known at compile-time and the vector table is created accordingly using the VEC_ENTRY assembly macro. But I have some ISR routines that will be determined only at runtime. I would like to write a function where I pass a function (ISR routine) pointer and the number of the IRQ.

Apart from disabling interrupts and enabling them afterwards, what are the steps for modifying the vector table? Is there an example (assembly or C)? I was thinking of determining the absolute address of the IRQ in the table using the chosen IRQ number and calling the VEC_ENTRY macro with the address of my function. Please provide an example on how you would achieve my goal.

Thanks in advance!

SC

  • Why can't you have a single ISR function that conditionally calls the different processing routines? The ISR function can check some global flag that indicates which processing routine should be used? That way you dont have to modify your vector table?

  • Hi Gagan,

    I was looking to write a function that does something similar to the Hwi_create() BIOS function. That way, I could dynamically associate a peripheral's ISR with a given IRQ. Does this BIOS function modify the vector table?

    I tried to imagine something equivalent using your suggestion but the only thing that comes to mind is using the Event Combiner. But then I would have potentially more than one combined event because the peripherals' IRQ/event numbers could fall into different ranges (4-31, 32-63, 64-95, 96-127).

    Is this what you are suggesting?

    Thanks,

    SC

  • Hi Gagan,

    Or maybe I could create a table in memory containing the lines of a vector table entry using the address of the ISR. Then I could copy the entry onto the vector table at the right absolute address. Could this work?

    Regards,

    SC

  • Hi,

    Can you please explain in greater detail your approach? My project is still set up for a static (compile-time) vector table setup (for debug) but I will soon have to make it dynamic.

    Thank you.

    SC

  • I haven't dealt with C6747 IRQ handling. Usually let the OS take care of it. On other platforms that have a fixed vector table, I usually make my own vector table that is called from the fixed vector handlers. Some uncompiled example code below.

    typedef int (*MyFuncPtrType)(int param);

    #define MY_VECTOR_NUM_0   0
    #define MY_VECTOR_NUM_1   1
    #define MY_VECTOR_NUM_2   2
    #define MY_VECTOR_NUM_MAX 3

    MyFuncPtrType myTable[MY_VECTOR_NUM_MAX];

    int MyVector0Handler(int param) { return 0};
    int MyVector1Handler(int param) { return 0};
    int MyVector2Handler(int param) { return 0};

    void MyTableInit(void)
    {
      myTable[MY_VECTOR_NUM_0] = MyVector0Handler;
      myTable[MY_VECTOR_NUM_1] = MyVector0Handler;
      myTable[MY_VECTOR_NUM_2] = MyVector0Handler;
    }

    int RealHandler(void)
    {
      int return_code;
      int param = 0;
      MyFuncPtrType func = myTable[MY_VECTOR_NUM_0];

      return_code = func(param);
    }

    int RealCombinedHandler(void)
    {
      int return_code;
      int param = 0;
      MyFuncPtrType func = myTable[MY_VECTOR_NUM_0];

      switch(some_irq_source)
      {
        case X:
          func = myTable[MY_VECTOR_NUM_1];
          return_code = func(param);
          break;
        case Y:
          func = myTable[MY_VECTOR_NUM_2];
          return_code = func(param);
          break;
      }
    }

  • Hi Norman,

    I understand. The fixed (compile-time) vector table is filled with jumps to unique generic ISRs. In each of these ISRs, I load the real ISR pointer from a my table filled dynamically. By default this table is filled with a pointer to a very simple ISR that only returns 0. If I want to do something else, I put my new ISR in this table and activate the corresponding IRQ.

    Thanks.

    SC