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.

AM3358: McASP configuration problems

Part Number: AM3358
Other Parts Discussed in Thread: SYSBIOS

I'm trying to use the McASP on a BBB.  I've been able to build the MCASP_Audio_evmAM335x_armExampleProject for the BBB and get the McASP initialized.  I've made all the changes to my project needed based on the sample project but it fails calling  mcaspBindDev.   Here's the configuration information:

Pinmux info

from bbbAM335x_pinmux.c

/* MCASP */

if(S_PASS == status)
{
status = PINMUXModuleConfig(CHIPDB_MOD_ID_MCASP, 0U, NULL);
}
if(S_PASS == status)
{
status = PINMUXModuleConfig(CHIPDB_MOD_ID_MCASP, 1U, NULL);
}

from am335x_beagleboneblack_pinmux_data.c

static pinmuxPerCfg_t gMcasp0PinCfg[] =
{
{
/* MyMCASP0 -> mcasp0_aclkr -> V2 */
PIN_LCD_DATA12, 0, \
( \
PIN_MODE(3) | \
((PIN_PULL_UD_EN | PIN_RX_ACTIVE) & (~PIN_PULL_TYPE_SEL)) \
) \
},
{
/* MyMCASP0 -> mcasp0_fsr -> V3 */
PIN_LCD_DATA13, 0, \
( \
PIN_MODE(3) | \
((PIN_PULL_UD_EN | PIN_RX_ACTIVE) & (~PIN_PULL_TYPE_SEL)) \
) \
},
{
/* MyMCASP0 -> mcasp0_axr0 -> U3 */
PIN_LCD_DATA10, 0, \
( \
PIN_MODE(3) | \
((PIN_PULL_UD_EN | PIN_RX_ACTIVE) & (~PIN_PULL_TYPE_SEL)) \
) \
},
{
/* MyMCASP0 -> mcasp0_axr1 -> V4 */
PIN_LCD_DATA14, 0, \
( \
PIN_MODE(3) | \
((PIN_PULL_UD_EN | PIN_RX_ACTIVE) & (~PIN_PULL_TYPE_SEL)) \
) \
},
{PINMUX_INVALID_PIN}
};

Config file 


/* ================ Driver configuration ================ */
//Load the EDMA package
var drv = xdc.loadPackage ("ti.sdo.edma3.drv");
var Edma = xdc.loadPackage ("ti.sdo.edma3.drv.sample");
var rm = xdc.loadPackage ("ti.sdo.edma3.rm");

var socType = "am335x";
var osType = "tirtos";


/* Load the OSAL package */
var Osal = xdc.useModule('ti.osal.Settings');
Osal.osType = osType;
Osal.socType = socType;

/*use CSL package*/
var Csl = xdc.loadPackage('ti.csl');
Csl.Settings.deviceType = socType;

/* Load Profiling package */
var Utils = xdc.loadPackage('ti.utils.profiling');

/* Load the uart package */
var UartPackage = xdc.loadPackage('ti.drv.uart');
UartPackage.Settings.enableProfiling = true;
UartPackage.Settings.socType = socType;

/* Load the spi package */
var Spi = xdc.loadPackage('ti.drv.spi');
Spi.Settings.socType = socType;

/* Load the driver packages, starting with mcasp */
var McASP = xdc.loadPackage('ti.drv.mcasp');
McASP.Settings.socType = socType;

/* Load the I2C package */
var I2c = xdc.loadPackage('ti.drv.i2c');
I2c.Settings.socType = socType;

/* Load the gpio package */
var GpioPackage = xdc.loadPackage('ti.drv.gpio');
GpioPackage.Settings.enableProfiling = true;
GpioPackage.Settings.socType = socType;

/* Load the board package */
var Board = xdc.loadPackage('ti.board');
Board.Settings.boardName = "bbbAM335x";


/* ================ Cache and MMU configuration ================ */

var Cache = xdc.useModule('ti.sysbios.family.arm.a8.Cache');
Cache.enableCache = true;

var Mmu = xdc.useModule('ti.sysbios.family.arm.a8.Mmu');
Mmu.enableMMU = true;

/* Force peripheral section to be NON cacheable strongly-ordered memory */
var peripheralAttrs = {
type : Mmu.FirstLevelDesc_SECTION, // SECTION descriptor
tex: 0,
bufferable : false, // bufferable
cacheable : false, // cacheable
shareable : false, // shareable
noexecute : true, // not executable
};


Mmu.setFirstLevelDescMeta(0x4ae00000, 0x4ae00000, peripheralAttrs);

/* CM_, PRM_ registers */
Mmu.setFirstLevelDescMeta(0x44E00000, 0x44E00000, peripheralAttrs);


/* edma */
for (var i=0x49000000; i < 0x49100000; i = i + 0x00200000) {
// Each 'BLOCK' descriptor entry spans a 2MB address range
Mmu.setFirstLevelDescMeta(i, i, peripheralAttrs);
}

for (var i=0x49800000; i < 0x49B00000; i = i + 0x00200000) {
// Each 'BLOCK' descriptor entry spans a 2MB address range
Mmu.setFirstLevelDescMeta(i, i, peripheralAttrs);
}

/* I2C0 */
// Each 'BLOCK' descriptor entry spans a 2MB address range
Mmu.setFirstLevelDescMeta(0x44e0b000, 0x44e0b000, peripheralAttrs);

/* I2C1 */
// Each 'BLOCK' descriptor entry spans a 2MB address range
Mmu.setFirstLevelDescMeta(0x4802A000, 0x4802A000, peripheralAttrs);
/* I2C2 */
// Each 'BLOCK' descriptor entry spans a 2MB address range
Mmu.setFirstLevelDescMeta(0x4819c000, 0x4819c000, peripheralAttrs);

/* GPIO */
/* Configure the corresponding MMU page descriptor accordingly */
Mmu.setFirstLevelDescMeta(0x44e00400, 0x44e00400, peripheralAttrs);
Mmu.setFirstLevelDescMeta(0x481a6000, 0x481a6000, peripheralAttrs);


/* mcasp-0 CFG*/
for (var i=0x48038000; i < 0x4803B000; i = i + 0x00200000) {
// Each 'BLOCK' descriptor entry spans a 2MB address range
Mmu.setFirstLevelDescMeta(i, i, peripheralAttrs);
}

/* mcasp-0 DATA */
for (var i=0x46000000; i < 0x46400000; i = i + 0x00200000) {
// Each 'BLOCK' descriptor entry spans a 2MB address range
Mmu.setFirstLevelDescMeta(i, i, peripheralAttrs);
}

I have added mcasp_soc.c to provide the McaspDevice_init() funcion.

Main.c

 

Int main()
{
Task_Handle task;
Error_Block eb;
Task_Params taskParams;
SPI_Params spiParams; /* SPI params structure */
SPI_Handle handle; /* SPI handle */

if (Board_initUART() == false)
{
System_printf("\nBoard_initUART failed!\n");
return (0);
}

UART_init();
GPIO_init();
McaspDevice_init();

Error_init(&eb);

/* Initialize the task params */
Task_Params_init(&taskParams);
taskParams.stackSize = 0x2000;
Task_create(testMcASP, &taskParams, &eb);

BIOS_start(); /* does not return */

return (0);
}

Void testMcASP()
{

EDMA3_DRV_Result edmaResult = 0;
Mcasp_HwInfo hwInfo;


Mcasp_socGetInitCfg(MCASP_NUM, &hwInfo);

enableEDMAHwEvent(EDMACC_NUM,MCASP_RX_DMA_CH);
enableEDMAHwEvent(EDMACC_NUM,MCASP_TX_DMA_CH);

hwInfo.dmaHandle = edma3init(0, &edmaResult);

/* McASP Device handles */
Ptr hMcaspDev;
/* McASP Device parameters */
Mcasp_Params mcaspParams;

/* Channel Handles */
Ptr hMcaspTxChan;
Ptr hMcaspRxChan;


Mcasp_socSetInitCfg(MCASP_NUM, &hwInfo);


mcaspParams = Mcasp_PARAMS;
//configure the McASP to get IMU data
int status = mcaspBindDev(&hMcaspDev, MCASP_NUM, &mcaspParams);   <--- This call fails

/* Create Mcasp channel for Rx */
status = mcaspCreateChan(&hMcaspRxChan, hMcaspDev, MCASP_INPUT,
&mcasp_chanparam[0], mcaspAppCallback, NULL);

MCASP_Packet rxFrame;
char data[EXPECTED_IMU_LENGTH];

/* Issue an empty buffer to the input stream */
rxFrame.cmd = MCASP_READ;
rxFrame.addr = (void*) data;
rxFrame.size = EXPECTED_IMU_LENGTH;
rxFrame.arg = (uintptr_t) hMcaspRxChan;
rxFrame.status = 0;
rxFrame.misc = 1; /* reserved - used in callback to indicate asynch packet */

status = mcaspSubmitChan(hMcaspRxChan, &rxFrame);

//if((status != MCASP_PENDING))

}

Stepping into the call I found that it's failing when trying to reset the McASP device on the line that writes to the config register


Debug output


[CortxA8] 0x48038000 R8 = 0x00000001
R1 = 0x80044318 R9 = 0x00000001
R2 = 0x000006ba R10 = 0x81257428
R3 = 0x00000000 R11 = 0x81058c84
R4 = 0x812576e4 R12 = 0x81058c88
R5 = 0x81257428 SP(R13) = 0x81058c68
R6 = 0x81257430 LR(R14) = 0x8002b398
R7 = 0x00000000 PC(R15) = 0x800350d8
PSR = 0x6000019f
DFSR = 0x00001808 IFSR = 0x00000000
DFAR = 0x48038044 IFAR = 0x00000000
ti.sysbios.family.arm.exc.Exception: line 205: E_dataAbort: pc = 0x800350d8, lr = 0x8002b398.
xdc.runtime.Error.raise: terminating execution

When I run the sample application this succeeds.  I've gone through my app and the sample app line by line and cant figure out what I'm missing.  Any help would be appreciated!

  • Hi Shawn,

    In evmAM335x board, we have audio codec AIC3x, while in bbbAM335x board, we have TDA19988 HDMI module attached to McASP0, check below e2e thread:

    https://e2e.ti.com/support/processors/f/791/t/828466

    Could you please provide more details regarding McASP audio usecase in bbbAM335x board? Do you need to use TDA19988 module?

    Regards,
    Pavel

  • Hi Pavel,

    I'm not using it for an audio application, so I don't need an audio codec.  It's being used to receive data from a source that has a data line, frame sync and clock.  Similar to the soft-uart implementation using the PRU. 

    http://processors.wiki.ti.com/index.php/Soft-UART_Implementation_on_AM335X_PRU_-_Software_Users_Guide

    I'm currently unable to initialize the device.  So at this point the use case is fairly irrelevant.

    Thanks

    Shawn

  • Shawn,

    Which evmAM335x McASP example you take as a reference? is it the below one?

    pdk_am335x_1_0_16/packages/ti/drv/mcasp/example/evmAM335x/armv7/bios/MCASP_Audio_evmAM335x_armExampleProject.txt

    Does you code hang/stuck at below line of code?

    mcaspBindDev() -> Mcasp_localSetupHwInfo() -> McASPGlobalCtlReset()

    pdk_am335x_1_0_16/packages/ti/csl/src/ip/mcasp/V1/priv/mcasp.c

    void McASPGlobalCtlReset(uint32_t baseAddr)
    {
        HW_WR_REG32(baseAddr + MCASP_GBLCTL, MCASP_RESET);   ----> hang/stuck here?
    }

     

    If that is correct, you need to ensure that McASP module you are using (McASP0 or McASP1) is enabled in device PRCM, check registers values:

    CM_PER_MCASP0_CLKCTRL
    CM_PER_MCASP1_CLKCTRL

    Then if you are using external clocks (aclkx, ahclkx), these should be enabled prior writing to GBLCTL register. If not using, these should be disabled in register AHCLKXCTL, ACLKXCTL. Check below AM335x TRM section for details:

    22.3.12.2 Transmit/Receive Section Initialization

    22.4.1.8 GBLCTL Register

  • Hi Pavel,

    Thanks for the help, that did the trick.  In the sample, MCASP_Audio_evmAM335x_armExampleProject, they have a call to enable the clock

    /// if the audio codec loopback is selected, eanble the clock for McASP 1
    /* For McASP1 clock setting */
    HWREG(SOC_PRCM_REGS + CM_PER_MCASP1_CLKCTRL) = CM_PER_MCASP1_CLKCTRL_MODULEMODE_ENABLE ;

    Because I'm using an external clock I didn't think the call was necessary.  But it appears it also enables the device as well as the clock.  Adding this for McASP0 fixed the exception from mcaspBindDev.

    HWREG(SOC_PRCM_REGS + CM_PER_MCASP0_CLKCTRL) = CM_PER_MCASP0_CLKCTRL_MODULEMODE_ENABLE ;

    Thanks for your help.

    Shawn

  • Shawn,

    Glad to see you have fix it.

    Please close/verify/resolve this thread.

    Regards,
    Pavel