AM62L FreeRTOS SDK  11.02.00
MCASP

The Multi Channel Audio Seiral Peripheral (MCASP) driver is a generic, full-duplex driver that transmits and receives data using the MCASP interface. This is specially designed to transmit and receive the digital audio data.

Features Supported

  • Interrupt mode operation
  • DMA mode operation
  • Internal Loopback
  • Transmit and Receive in TDM format with multi-serializer, multi-slot support.
  • SysConfig support for driver parameter configuration and initialization.

SysConfig Features

Attention
The instances for McASP needs to be selected the same for serializers for the instance. Syscfg will automatically assign different instances for all and user will be required to assign same instance and choose to ignore the warning.
Note
It is strongly recommend to use SysConfig where it is available instead of using direct SW API calls. This will help simplify the SW application and also catch common mistakes early in the development cycle.

Features NOT Supported

  • Transmit in DIT mode
  • Burst Mode
  • Different audio buffer format for application

Usage Overview

Key Careabouts in Driver Usage

Note
The changes pulled in for the driver starting release 10.0 requires some changes in the Driver usage from application
  • All transactions submitted from the applications must be of the same size.
    • The TX and RX can be of seperate size.
  • The Loopjob buffer size can be configured from the sysconfig.
  • Application can provide an external buffer for loopjob buffer from Sysconfig
    • This enables application to provide the transaction buffer itself as loopjob
  • MCASP_stopTransferRx() and MCASP_stopTransferTx() are blocking calls that should not be called from an ISR context.

API Sequence

To use the MCASP driver to send data over the MCASP interface, the application calls the following APIs:

Loopjob Configuration

Mcasp driver allows loopjob enabled/disabled configuration to handle delayed application buffer submission at run time. Loopjob is a default buffer that gets transmitted / received into if the application fails to submit the buffers in time. When loopjob is disabled the last 2 application buffers will be re programmed and re used. The application callback corresponding to the re programmed buffers is not called.

  • Loopjob buffer is programmed in sys config. Sys config will define a uint8_t array and initialize it to 0.
  • Application can access the buffer and optionally initialize the data.
  • If the loopjob buffer is programmed, after sending the full loopjob buffer next submitted buffer is programmed.

Buffer Queuing

  • The application buffers need to be programmed before starting the transfer.
  • If the loopjob is enabled application can start without queuing any buffers, Driver will work with the loopjob buffers till application queues the actual buffers.
  • If loopjob is disabled at least 2 buffers should be queued before starting the mcasp transfer. New buffer will be programmed in the interrupt callback corresponding to current transfer. the application is expected to submit the new buffer before that else the same buffer is re programmed, so it is recommended to start the transfer with at least 3 buffers queued.

Example Usage

Include the below file to access the APIs

#include <drivers/mcasp.h>

Instance Open Example

MCASP_OpenParams mcaspParams;
MCASP_openParamsInit(&mcaspParams); /* Initialize mcasp parameters */
mcaspParams.edmaInst = 0;
mcaspParams.edmaInst = CONFIG_EDMA0,
mcaspParams.txCallbackFxn = mcasp_loopback_txcb,
mcaspParams.rxCallbackFxn = mcasp_loopback_rxcb,
gMcaspHandle = MCASP_open(CONFIG_MCASP0, &mcaspParams);
DebugP_assert(gMcaspHandle != NULL);

Instance Close Example

MCASP_close(gMcaspHandle);

Start McASP Transfer Example

MCASP_Transaction txnTx[APP_MCASP_MSG_COUNT] = {0};
MCASP_Transaction txnRx[APP_MCASP_MSG_COUNT] = {0};
uint8_t mcaspTxBuffer[APP_MCASP_MSG_COUNT][APP_MCASP_MSGSIZE];
uint8_t mcaspRxBuffer[APP_MCASP_MSG_COUNT][APP_MCASP_MSGSIZE];
uint32_t i;
for (i = 0U; i < APP_MCASP_MSG_COUNT; i++)
{
txnTx[i].buf = (void*) &mcaspTxBuffer[i][0];
txnTx[i].count = APP_MCASP_MSGSIZE/4;
txnTx[i].timeout = 0xFFFFFF;
MCASP_submitTx(gMcaspHandle, &txnTx[i]);
}
for (i = 0U; i < APP_MCASP_MSG_COUNT; i++)
{
txnRx[i].buf = (void*) &mcaspRxBuffer[i][0];
txnRx[i].count = APP_MCASP_MSGSIZE/4;
txnRx[i].timeout = 0xFFFFFF;
MCASP_submitRx(gMcaspHandle, &txnRx[i]);
}
MCASP_startTransferRx(gMcaspHandle);
MCASP_startTransferTx(gMcaspHandle);

Stop McASP Transfer Example

MCASP_stopTransferTx(gMcaspHandle);
MCASP_stopTransferRx(gMcaspHandle);
/* withdraw the buffers submitted to driver. */
{
MCASP_Transaction *transaction;
do {
transaction = MCASP_withdrawRx(gMcaspHandle);
}while (transaction != NULL);
do {
transaction = MCASP_withdrawTx(gMcaspHandle);
}while (transaction != NULL);
}

SysConfig migration guide 11.01 to 11.02

Note
This section highlights key features that have changed or got added from 11.01 to 11.02 SDK

AUX clock selection

  • This version of SDK (11.02) gives the configurability to choose between different sources of AUXCLK

MCASP AUX Clock selection
  • The specific option for AUXCLK will vary from device to device. View long description in Syscfg view for more details on the AUXCLK options to select from.
  • The frequency for the configurable AUX clock options can be choosen at a global level as this will be applicable across all instances of MCASP.

MCASP AUX Clock Frequency Configuration
  • Some option in the AUX clock selections might expect the aux clock to be supplied externally to the SoC. Refer the TRM of the specific device to check if the clock is supplied externally or generated interally.
  • When using an internally generated auxiliary clock source, not all frequency values are achievable due to hardware limitations. If the user-specified frequency cannot be generated, the system will throw a runtime error.

Clock Divider Configurability

  • This version of SDK (11.02) gives configurability of the High Clock Divider (HCLK Divider), and the BCLK divider.

MCASP Clock Divider Configuration
  • The "Re-Calculate" button can be used to calculate the divider values that would result in the closest FSYNC value required.
  • The "Apply" button needs to be pressed to view the frequencies for any change in the Sysconfig GUI that have resulted in a change of frequencies.
  • Press the "Apply" button to update the frequency information displayed in the Syscfg GUI for all configuration parameters that affect frequency settings.
  • User have to ensure all the frequencies that is displayed is as expected in the system after pressing "Apply".
  • User can adjust the Divider values and press the "Apply" button to achieve any specific clock frequencies.

API

APIs for MCASP

MCASP_withdrawRx
MCASP_Transaction * MCASP_withdrawRx(MCASP_Handle handle)
Function to withdraw the buffer submitted to McASP driver for reception. This should be called after ...
MCASP_close
void MCASP_close(MCASP_Handle handle)
Function to close a MCASP peripheral specified by the MCASP handle.
MCASP_submitRx
int32_t MCASP_submitRx(MCASP_Handle handle, MCASP_Transaction *txn)
Function to submit the buffer to McASP driver for reception. Transaction object is held by the driver...
MCASP_withdrawTx
MCASP_Transaction * MCASP_withdrawTx(MCASP_Handle handle)
Function to withdraw the buffer submitted to McASP driver for transmission. This should be called aft...
NULL
#define NULL
Define NULL if not defined.
Definition: csl_types.h:100
MCASP_OpenParams::rxCallbackFxn
MCASP_RxCallbackFxn rxCallbackFxn
Definition: mcasp/v1/mcasp.h:530
MCASP_open
MCASP_Handle MCASP_open(uint32_t index, const MCASP_OpenParams *openParams)
This function opens a given MCASP peripheral.
MCASP_Transaction
Data structure used with transfer call.
Definition: mcasp/v1/mcasp.h:347
MCASP_OpenParams
MCASP Parameters.
Definition: mcasp/v1/mcasp.h:509
MCASP_stopTransferRx
int32_t MCASP_stopTransferRx(MCASP_Handle handle)
Function to stop McASP reception.
MCASP_OpenParams::transferMode
uint32_t transferMode
Definition: mcasp/v1/mcasp.h:510
MCASP_Transaction::count
uint32_t count
Definition: mcasp/v1/mcasp.h:354
MCASP_startTransferTx
int32_t MCASP_startTransferTx(MCASP_Handle handle)
Function to start McASP transmission.
MCASP_OpenParams::txCallbackFxn
MCASP_TxCallbackFxn txCallbackFxn
Definition: mcasp/v1/mcasp.h:528
mcasp.h
MCASP_openParamsInit
static void MCASP_openParamsInit(MCASP_OpenParams *openPrms)
Function to initialize the MCASP_OpenParams struct to its defaults.
Definition: mcasp/v1/mcasp.h:939
MCASP_startTransferRx
int32_t MCASP_startTransferRx(MCASP_Handle handle)
Function to start McASP reception.
MCASP_Transaction::timeout
uint32_t timeout
Definition: mcasp/v1/mcasp.h:358
DebugP_assert
#define DebugP_assert(expression)
Function to call for assert check.
Definition: DebugP.h:183
MCASP_Transaction::buf
void * buf
Definition: mcasp/v1/mcasp.h:351
MCASP_submitTx
int32_t MCASP_submitTx(MCASP_Handle handle, MCASP_Transaction *txn)
Function to submit the buffer to McASP driver for transmission. Transaction object is held by the dri...
MCASP_TRANSFER_MODE_DMA
#define MCASP_TRANSFER_MODE_DMA
MCASP read/write APIs does not block code execution and will use DMA for transfers.
Definition: mcasp/v1/mcasp.h:166
MCASP_stopTransferTx
int32_t MCASP_stopTransferTx(MCASP_Handle handle)
Function to stop McASP transmission.