S32K3 + SGTL5000 SAItoI2S Codec

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K3 + SGTL5000 SAItoI2S Codec

1,138 Views
iverson3ya
Contributor III

I encountered some issues during testing when sending, as shown in the image below.

iverson3ya_0-1699002849664.png

I2s_MasterRequest.bufferSize = 260760;//SAI_IP_MAX_NO_OF_FRAMES-1;

If it exceeds SAI_IP_MAX_NO_OF_FRAMES (32767UL), it seems to have this issue.

There appears to be a limitation underneath Sai_Ip_Send, but I checked the demo code, and this restriction 'DevAssert(u32Count < SAI_IP_MAX_NO_OF_FRAMES);' is not there.

So, I commented it out. If this limitation is indeed necessary, how can I play the complete audio file?

 

void SGTL5000_SAI_test1(void)
{

    volatile boolean bStatus = TRUE;

    /* Create Master/Slave request */
    I2s_MasterRequest.bufferSize = 260760;//SAI_IP_MAX_NO_OF_FRAMES-1;
    I2s_MasterRequest.dataDirection = I2S_SEND_DATA;
    I2s_MasterRequest.pDataBuffer = (I2s_DataType (**))SendData;
    I2s_MasterRequest.autoDisableClock = true;

    I2s_SlaveRequest.bufferSize = BUFF_SIZE - 1U;
    I2s_SlaveRequest.dataDirection = I2S_RECEIVE_DATA;
    I2s_SlaveRequest.pDataBuffer = (I2s_DataType (**))RecvData;

    /* Init buffer data */
    for (int i = 0; i < BUFF_SIZE; i++)
    {
        SendData1[i] = i + 1U;
        RecvBuff1[i] = 0U;
    }

//  pRequest = &I2s_SlaveRequest;
//  Ret = I2s_AsyncTransmit(I2S_SAI_RX, pRequest);
//    if (E_NOT_OK == Ret)
//    {
//        bStatus = FALSE;
//    }

     /* Start sending data */
    pRequest = &I2s_MasterRequest;
    Ret = I2s_AsyncTransmit(I2S_SAI_MASTER, pRequest);
    if (E_NOT_OK == Ret)
    {
        bStatus = FALSE;
    }
   
   vTaskDelay(10000);

    I2s_GetStatus(I2S_SAI_MASTER, &transferStatus);
    if ((I2S_STATUS_COMPLETED != transferStatus.status) || (0U != transferStatus.byteRemainCount))
    {
        bStatus = FALSE;
    }

}
 
 
Additionally, how can I configure SAI0 in the same group to be able to receive as well? Changing the direction using 'I2s_SlaveRequest.dataDirection = I2S_RECEIVE_DATA;' doesn't seem to work.
 
thanks!

 

 

0 Kudos
Reply
4 Replies

958 Views
iverson3ya
Contributor III

Problem solved

thanks

1,096 Views
nxf78987
NXP Employee
NXP Employee

Hello @iverson3ya,

What is the RTD package you are using?

Best regards,

Dan

0 Kudos
Reply

1,075 Views
iverson3ya
Contributor III

I am using RTD3.0.0, and I have already resolved the thread issue. However, I am now facing a new problem where interrupts often do not trigger.

After I2S reinitialization, it will work properly

void I2s_ReceiverNotification(Sai_Ip_ReportType event)
{
    RxEven = event;
    if( event == SAI_IP_RX_COMPLETE){
        RxFlag = TRUE;
    }
}
void SGTL5000_SAI_PlayRecord(void)
{

    volatile boolean bStatus = TRUE;
    uint32 timeout = 100000000U;

    /* Create Master/Slave request */
    I2s_MasterRequest.bufferSize = BUFF_SIZE - 1U;
    I2s_MasterRequest.dataDirection = I2S_SEND_DATA;
    I2s_MasterRequest.pDataBuffer = (I2s_DataType (**))RecvData;
    // I2s_MasterRequest.autoDisableClock = true;

    I2s_SlaveRequest.bufferSize = BUFF_SIZE - 1U;
    I2s_SlaveRequest.dataDirection = I2S_RECEIVE_DATA;
    I2s_SlaveRequest.pDataBuffer = (I2s_DataType (**))RecvData;
    // I2s_SlaveRequest.autoDisableClock = true;
    /* Init buffer data */
    for (int i = 0; i < BUFF_SIZE; i++)
    {
        //SendData1[i] = i + 1U;
        RecvBuff1[i] = 0U;
    }
start:
    for (int i = 0; i < 10; i++){
        pRequest = &I2s_SlaveRequest;
        Ret = I2s_AsyncTransmit(I2S_SAI_RX, pRequest);
        if (E_NOT_OK == Ret)
        {
            bStatus = FALSE;
        }

        while (!RxFlag && timeout){
            timeout--;
            if(timeout <= 0){
                I2s_AbortTransmit(I2S_SAI_RX);
                I2s_Init(&I2s_xConfig_VS_0);
                printf("RX timeout and init I2S\r\n");
                goto start;
            }
        }
        timeout = 100000000U;
        I2s_AbortTransmit(I2S_SAI_RX);
        RxFlag = FALSE;

        switch(RxEven)
        {
            case SAI_IP_RX_COMPLETE:
                printf("RX SAI_IP_RX_COMPLETE\r\n");
                break;
            case SAI_IP_ERROR:
                printf("RX SAI_IP_ERROR\r\n");
                break;
            case SAI_IP_FRAME_START:
                break;
            case SAI_IP_RUN_ERROR:
                printf("RX SAI_IP_RUN_ERROR\r\n");
                break;
            case SAI_IP_SYNC_ERROR:
                printf("RX SAI_IP_SYNC_ERROR\r\n");
                break;
            default:
                break;
        }

        /* Start sending data */
        pRequest = &I2s_MasterRequest;
        Ret = I2s_AsyncTransmit(I2S_SAI_MASTER, pRequest);
        if (E_NOT_OK == Ret)
        {
            bStatus = FALSE;
        }

        while (!TxFlag);
        I2s_AbortTransmit(I2S_SAI_MASTER);
        TxFlag = FALSE;
        switch(TxEven)
        {
            case SAI_IP_TX_COMPLETE:
                printf("TX SAI_IP_TX_COMPLETE\r\n");
                break;
            case SAI_IP_ERROR:
                printf("TX SAI_IP_ERROR\r\n");
                break;
            case SAI_IP_FRAME_START:
                break;
            case SAI_IP_RUN_ERROR:
                printf("TX SAI_IP_RUN_ERROR\r\n");
                break;
            case SAI_IP_SYNC_ERROR:
                printf("TX SAI_IP_SYNC_ERROR\r\n");
                break;
            default:
                break;
        }

        I2s_GetStatus(I2S_SAI_MASTER, &transferStatus);
        while ((I2S_STATUS_COMPLETED != transferStatus.status) || (0U != transferStatus.byteRemainCount)){
            I2s_GetStatus(I2S_SAI_MASTER, &transferStatus);
        }
        I2s_AbortTransmit(I2S_SAI_RX);
        I2s_AbortTransmit(I2S_SAI_MASTER);
        if(gUart_Cmd_ISR_Flag == true){
            gUart_Cmd_ISR_Flag = false;
            break;
        }  
    }
}
0 Kudos
Reply

976 Views
nxf78987
NXP Employee
NXP Employee

Hello @iverson3ya,

Could you show me the value of SAI registers when interrupts does not trigger?

Best regards,

Dan

0 Kudos
Reply