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.

Compiler/TMS320F28379D: Lab and Example code for TMS320F28379D - Interruption and PieCtrl.c

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software: TI C/C++ Compiler

I have been done the Multiday Lab WorkShop for the TMS320F28379D LaunchPad and the PieCtrl.c file explicit show the folow line to initialize de PIE RAM:

//--- Initialize the PIE_RAM. There are:

//   32 base vectors + (12 PIE groups * 16 vectors/group) = 224 PIE vectors (448 words).

       PieCtrlRegs.PIECTRL.bit.ENPIE = 0;      // Disable the PIE

      asm(" EALLOW");                  // Enable EALLOW protected register access

       // Step around the first three 32-bit locations (six 16-bit locations).

       // These locations are used by the ROM bootloader during debug.

       memcpy((Uint16 *)&PieVectTable+6, (Uint16 *)&PieVectTableInit+6, 448-6);

       asm(" EDIS");                     // Disable EALLOW protected register access

But in the example provided in the CCSv7 I was not able to find the code for the memory copy.

So the question is where that code is, I mean, where is:

       memcpy((Uint16 *)&PieVectTable+6, (Uint16 *)&PieVectTableInit+6, 448-6);

in the example provided?

Or, in another way, is there other way to copy the table vector to the RAM? In this case how is it done?

Thank you in advance,

Pedro A.

I have been done the Mul

  • Hi Pedro,

    Look at the file F2837xD_PieVect.c in C2000Ware/device_support/f2837xd/common/source. It contains the function "InitPieVectTable" that properly initializes the PIE table.

  • Thank you Frank,
    It helps me, but I would like to understand how the address of the interruption is obtained from the code and why the Source pointer is been copyed to the Des pointer and is no more used:

    void InitPieVectTable(void)
    {
    Uint16 i;
    Uint32 *Source = (void *) &PieVectTableInit;
    Uint32 *Dest = (void *) &PieVectTable;
    //
    // Do not write over first 3 32-bit locations (these locations are
    // initialized by Boot ROM with boot variables)
    //
    Source = Source + 3;
    Dest = Dest + 3;

    EALLOW;
    for(i = 0; i < 221; i++)
    {
    *Dest++ = *Source++;
    }
    EDIS;

    //
    // Enable the PIE Vector Table
    //
    PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
    }

    Thank you again,
    Pedro A
  • Ok let me see if I have correct understandment ...
    That is a pointer to a function, in this case a structure, that is initialized for the first address of the structure, that have the name of interruption (defined in PieVectTableInit). The objective is to give to the names of the interruption (something_ISR, in PieVectTableInit) the interruption type, defined in the other structure (PieVectTable).
    Am I right?
    Thank you,
    Pedro A.
  • Pedro,

    Yes. When a peripheral interrupt that is enabled occurs, the CPU goes to the PIE vector table to retrieve the vector/address of the ISR function to call so at any point in time, the PIE vector table has to contain valid addresses even if the functions the table points to are placeholder functions and don't really do anything. If the table is not properly initialized before the PIE is enabled, an interrupt can cause the code to go into the weeds.

    In the above code snippet, the destination is a pointer to the starting address of the PIE vector table and the source is the address of structure constant with function pointers as members. These placeholder functions populate the PIE vector table after that for loop.

    In your code, you have to overwrite each PIE placeholder vector with the function you want called when an interrupt occurs.
  • Thank you Frank,
    This answered my doubt.
    Pedro A.