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.

HWI_enter/HWI_exit macro build error OMAPL138

Other Parts Discussed in Thread: OMAPL138

Hi All

Background :

Using c6748 DSP of OMAPL138 with CCS4.2; BIOS 5_41_10_36; BIOSPSP 01_30_01; EDMA3_LLD_01_11_02_03.

We have implemented a SPI/EDMA driver with asynchronous call-back.

We recieve an interrupt and within the hardware isr() call GIO_submit() with a callback function.

In the callback function we SWI_post() to offset processing (since we know the callback function is still in the interrupt context) - because we are in the interrupt context we must use HWI_enter/HWI_exit macro pair. Illustrated below.........

-------------------------------------------------------------------------------------------------------------------------------------------

isr()    // external HWI_6 interrupt

{

   Gio_submit( x ,y ,z ,w, &spi_dma_callback)

}

spi_dma_callback() // Checked here if in interrupt context using HWI_isHWI() - we are ie PSP doesn't use dispatcher

{

    HWI_enter C64_ATEMPS, C64_BTEMPS, C64_CTEMPS, 0xFFFF, 0   

        SWI_post(&spiTest);

    HWI_exit C64_ATEMPS, C64_BTEMPS, C64_CTEMPS, 0xFFFF, 0

}

-------------------------------------------------------------------------------------------------------------------------------------------

In our build options we have

C/C++ build -> Macros - > system macros

BIOS_INCLUDE_DIR           c:/bios_5_41_10_26/packages/ti\bios/include

C/C++ build ->C6000 Compiler -> Include Options

"${BIOS_INCLUDE_DIR}"

Problem :

Using #include <hwi.h> the HWI_enter word is not picked up or defined and we get the following errors

#102: "C64_ATEMPS" has already been declared in the current scope    hucl_esm_dsp    spiThread.c    line 340    1334840845817    5774
#102: "C64_BTEMPS" has already been declared in the current scope    hucl_esm_dsp    spiThread.c    line 340    1334840845817    5775
#102: "C64_CTEMPS" has already been declared in the current scope    hucl_esm_dsp    spiThread.c    line 340    1334840845817    5776
#20: identifier "HWI_enter" is undefined    hucl_esm_dsp    spiThread.c    line 325    1334840845817    5770
#20: identifier "HWI_exit" is undefined    hucl_esm_dsp    spiThread.c    line 340    1334840845817    5773
#270: declaration may not appear after executable statement in block    hucl_esm_dsp    spiThread.c    line 340    1334840845817    5772
#41: expected an identifier    hucl_esm_dsp    spiThread.c    line 325    1334840845817    5771
#41: expected an identifier    hucl_esm_dsp    spiThread.c    line 340    1334840845817    5777

The HWI_enter macro's etc are  contained in assembler files  "c64.h64" and "hwi.h62" but the compiler will not recognise these and if we try to include them we get multiple errors.

This must be a known issue when using asynchronous callbacks with the SPI/EDMA3 driver - is there a WIKI page detailing how to resolve this easily ? I would assume most people would attempt to get out of the interrupt context asap so CPU could actually do some processing.

Many Thanks In Advance

BR

Barry











  • Hi Barry,

    HWI_enter and HWI_exit are assembly macros.  As such, they must be used in assembly language context.

    Steve

  • Hi Steve

    Thanks for the prompt reply.

    My latter post was somewhat hurried as I was trying to avoid the forum maintenance time-out.

    We did realise the problem was due to the assembly nature of the macro. What we haven't seen is an example of how this assembly macro can be incorporated and used with the PSP in a typical scenario (being used in C context).

    Are there any examples of these important macro's being used in a such a way?

    Many Thanks

    Barry

  • Hi Barry,

    Is there a reason you're not using the HWI dispatcher?  If you use the dispatcher, then you don't need to worry about these _enter/_exit macros.

    But, if you don't want to use the dispatcher, then to use the HWI_enter/_exit macros you'll need to write a little bit of assembly code.

    One way to do this would be to write an assembly interrupt service routine that's mapped to your HWI so that it runs when the interrupt fires.  Call HWI_enter.  Then SEM_post (you may need to call a C function from within your assembly ISR).  Then call HWI_exit.

    Steve

  • Hi Steve

    We do use the dispatcher for our project and our FPGA  interrupt (hence don't use HWI_enter/HWI_exit).

    The problem arises because our SPI/EDMA implementation uses the platform support package (PSP). We use GIO_submit()  (see User Guide - OMAPL138 BIOS PSP User Guide 01.30.01). This is  pre-built package and when the EDMA competes the asynchronous transfer a pre-defined call-back function is called as follows

     --------------PSEUDO initialisation code - Left out PIN MUX and GPIO interrupt configuration   -------------------------------

    GIO_Handle  spiHandle  = NULL;

    GIO_AppCallback  spi_dma_callback1;

    GIO_Attrs           gioAttrs            = GIO_ATTRS;
    Spi_ChanParams      chanParams;

    chanParams.hEdma = hEdma[0];

    spiHandle =  GIO_create("/Spi1",IOM_INOUT,NULL,&chanParams,&gioAttrs);

    spi_dma_callback1.fxn = spi_dma_callback1_fn;  
    spi_dma_callback1.arg = &loopRead1[0];

        memset(&dataparam1,0x00, sizeof(Spi_DataParam));
        dataparam1.chipSelect   = SPI1_SCS1;        
        dataparam1.bufLen       = sizeof(loopWrite);
        dataparam1.flags        = FALSE;                    
        dataparam1.dataFormat   = Spi_DataFormat_0;   
        dataparam1.outBuffer    = NULL;
        dataparam1.inBuffer     = (Uint8*)loopRead1;

    --------------------------------------------------------------------------------------------------------------------------

    ----------------------------------- Our FPGA Interrupt routine - written using dispatcher --------------

    void fpgaInputIsr(Ptr gp0_0_Interrupt)

    {

        Int      status = IOM_COMPLETED;

        gpioIntStatus = gpioRegs->BANK[GPIO_BANK_0].INTSTAT; 

        if (gpioIntStatus & CSL_GPIO_INTSTAT_STAT10_MASK)

            Bank0Isr10 +=1;

       else

            UnknownIsr +=1;

        Gpio_clearInterruptStatus(gpio0,&pinCmdArg);     

        status = GIO_submit(spiHandle, IOM_READ, &dataparam1, &(dataparam1.bufLen), &spi_dma_callback1);  

        if( !((IOM_COMPLETED != status) || (IOM_PENDING != status)) )

        {

            gioSubtErr++;
            while(1);

       }

        return;

    }

    ----------------------------------------------------------------------------------------------------------------------------------

    ------------------------------------------ Asynchronous Callback function used by PSP ------------------------

    void spi_dma_callback1_fn(Ptr arg, Int status, Ptr buf, size_t size)
    {
     
        if(IOM_COMPLETED == status || -13 == status) {     
            SWI_post(&testSWI);                                                    --------- OUR PROBLEM - how to SWI_post() here correctly
        }else {
            spiDmaFail1++;
    }

    ----------------------------------------------------------------------------------------------------------------------------------

    I am not sure how how to implement an assembly wrapper in this context as we do not have access to the dispatcher of the PSP. We have checked by placing a HWI_isHWI() call within spi_dma_callback1_fn() and it shows we are in the hardware context. 

    BUT - if the PSP is not using the dispatcher and we are in a hardware context should the callback function not have an INTERRUPT keyword in this case ?

    I also need to clarify how the PSP operating here. Our FPGA interrupt (h/w context) executes GIO_submit(). Is this the correct operation for the PSP

    1 : SPI/EDMA transfer initiated

    2 : We return from our FPGA hardware interrupt

    3 : The DMA controller and EDMA operate in the background giving TSKs etc time to execute.

    4: The callback function is executed and we return to hardware context.

    This is an asynchronous callback -  I am assuming when we execute the callback function we have not remained in the interrupt context the entire time. (ie from GIO_submit() to callback function).

    Clarification on these points would greatly help ..

    Many Thanks

    Barry

  • Hi Barry,

    barry mohan said:

    I also need to clarify how the PSP operating here. Our FPGA interrupt (h/w context) executes GIO_submit(). Is this the correct operation for the PSP

    1 : SPI/EDMA transfer initiated

    2 : We return from our FPGA hardware interrupt

    3 : The DMA controller and EDMA operate in the background giving TSKs etc time to execute.

    4: The callback function is executed and we return to hardware context.

    This is an asynchronous callback -  I am assuming when we execute the callback function we have not remained in the interrupt context the entire time. (ie from GIO_submit() to callback function).

    You are absolutely correct.

    The callback function that is registered during GIO_submit is invoked/called when the request completes. But the callback function is called in the hardware interrupt context itself. For more information on this, please refer BIOS Userguide for a brief description of  appCallback in "GIO_submit".

    Hope this helps..

    Best Regards,

    Raghavendra