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.

How to use error callback function with McASP peripheral?

Hi,

I am looking for some assistance with locating documentation regarding use of the error callback functions under CCS5.5 and SYS/BIOS 6.35 with an L137 device target. .

The McASP peripheral allows for a function pointer to an error callback function to be defined when initiialising the driver and device. 

The guidance I am looking for here is what is the purpose of the Int32 value parameter in the callback? What errors cause the callback to be initiated. From my own study of operation it would seem that the error callback is invoked whenever the XSTAT register has a bit set and there are corresponding bits set in the XINTCTL register. 

Once invoked what is the correct mechanism for clearing the error. I seem to have mixed success by clearing the XINTCTL bits but I'd like to locate documentation about how to use the error callback for the McASP in the context of the L138 and SYS/BIOS 6.35.

From my own project here are the relevant code snippets:

a) definition of error callback

extern Void errorFnx( Int32 value );

:

:

b) reference to callback initialised in channel parameters:


Mcasp_ChanParams chanParams = { 0x0001, /* Number of serialisers */ {Mcasp_SerializerNum_15, }, /* Serialiser index: AXR[15] is PCM Tx from Codec(s) */ &audio_info.mcaspXmtSetup, /* HW Config */ TRUE, /* DMA Driven */ Mcasp_OpMode_TDM, /* Mode (TDM/DIT) */ Mcasp_WordLength_16, /* Data Transfer Size */ NULL, /* Loop Job Buffer */ 0, /* Loop Buffer Length */ NULL, /* EDMA Driver Handle - filled in during Init */ &errorFnx, /* Error Callback fn pointer */ 16, /* Number of TDM channels */ Mcasp_BufferFormat_1SER_MULTISLOT_NON_INTERLEAVED, TRUE, /* Enable HW FIFO */ TRUE /* Buffer Data Packed */ }

:

:

c) Establishing the IO channel to the McASP:

    /*
    ** Create Output Stream
    */
    ioParams.chanParams = &chanParams;
    ioParams.model = GIO_Model_ISSUERECLAIM;
    chanParams.edmaHandle = hEdma;

    outStream = GIO_create("/mcasp0", GIO_OUTPUT, &ioParams, &eb);
    if(outStream == NULL)
    {
        System_printf("LOG:: Audio: Create Output stream FAILED\n");
        return(STATUS_FAIL);
    }
:
:

d) Declaring the error callback function:
extern Void errorFnx( Int32 value ) { #define SETBIT(dest,mask) (dest|=mask) #define CLRBIT(dest,mask) (dest&=~mask) #define CHKBIT(dest,mask) (dest&=mask) CSL_McaspRegsOvly mcaspRegs = (CSL_McaspRegsOvly) CSL_MCASP_0_CTRL_REGS; //OMAP-L138 McASP Configuration Register Pointer Instance CLRBIT( mcaspRegs->XSTAT, (CSL_MCASP_XSTAT_XCKFAIL_MASK |CSL_MCASP_XSTAT_XSYNCERR_MASK|CSL_MCASP_XSTAT_XUNDRN_MASK) ); mcasp_fault = 1; }

Thanks for any help and particularly pointers to the appropriate documentation/examples that details how to use the error call back. The SRUFM1.pdf does not seem to describe how the callback should be used, the meaning of the value parameters, etc.

Duncan.

  • Hi Duncan,

    The Error callback will be called/required when global error occurs must be callable directly from the ISR context .
    Their is not much of documentation on it. But now can see check an example project for McASP in BIOSPSP_03_00_01_00, at below mentioned path.
    ~\biospsp_03_00_01_00\drivers\examples\evm6748\audio
    and driver code at,
    ~\biospsp_03_00_01_00\drivers\mcasp

    For example when we call GIO_create API,

    Error_Block eb;
    Error_init(&eb);
    outStream = GIO_create("/mcasp0", GIO_OUTPUT, &ioParams, &eb);

    Here, we are passing last argument(&eb) a function pointer to an error, and it will be called it is not successful.
  • Hi Duncan,

    Is my suggestion helpful to you ?
    Are you able to register a callback function ?
  • Hi Arvind,

    Yes your answer was helpful. It uncovered a weakness in my approach. I was not checking the error_block using the XDC.runtime.Error function Error_check().

    Instead my error checking approach was:

    • check the IOM_ return codes from the GIO_create() and GIO_issue() and GIO_reclaim() GIO API calls.
    • define an error callback function via the channel structure when creating the channel.

    In my implementation, I found that the error callback function defined in the channel structure was called by the SYS/BIOS framework when McASP errors flagged in the XINTCTL and RINTCTL registers occurred. By placing a breakpoint in my error call back and looking at the call stack, I investigated the source code of the caller of my error handler. 

    I could see that the value parameter in my error call back was being set to an IOM_ error value prior to calling the callback. I also noted that that the framework was set the bits in the XSTAT register to clear the error so I was duplicating this activity in my own callback.

    I therefore see that the error callback called due to one of the McASP errors defined in the XINTCTL and RINTCTL occurring is a useful way of trapping runtime errors.

    The error_block you highlighted is a further, and very necessary, way of determine whether some other error occurred outwith those errors that are highlighted by the IOM_ return value.

    Thank you for your assistance.

    Duncan.

  • Duncan,

    Good to hear that you have uncovered more stuffs.
    Thanks for the update.