Initialising USB host interferes with SAI drivers

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

Initialising USB host interferes with SAI drivers

Jump to solution
637 Views
samtyler
Contributor I

Hi.

I'm trying to create an application which includes I2S and a USB device. I'm having a problem in which initialising the USB host drivers will cause the I2S callback to never be called.

Is there any over lap in the two drivers? Do they use common hardware? Is it likely to be caused by the tasks created in USB stack initialisation?

Offending code is shown below. The callback is repeatedly called when lines 27 to 32 are commented, but never when they are included.

Any comments / suggestions would be appreaciated.

Thanks in advance,

Sam

Code:

#if 1

#include "board.h"

#include "fsl_sai_driver.h"

#include "usb_host_config.h"

#include "usb.h"

#include "usb_host_stack_interface.h"

#include "usb_host_hub_sm.h"

#include "usb_host_ch9.h"

void i2s_callback(void* params)

{

    PRINTF("Callback\r\n");

}

static void primary_thread(void *params)

{

    const uint32_t size = 5120;

    uint8_t buffer[size];

    uint8_t instance = 0;

    uint32_t status;

    usb_host_handle host_handle;

    /* Uncommenting these lines causes SAI interrupt to never be called! */

//    status = usb_host_init(USB_CONTROLLER_KHCI_0, &host_handle);

//    if (status != USB_OK)

//    {

//        PRINTF("ERROR\r\n");

//        while(1);

//    }

    sai_user_config_t i2s_config;

    sai_state_t i2s_state = {0};

    sai_data_format_t i2s_data_format = {0};

    i2s_data_format.bits = 16;

    i2s_data_format.sample_rate = 8000;

    i2s_data_format.mclk = 13000000;

    i2s_data_format.mono_stereo = kSaiStereo;

    i2s_config.bclk_source = kSaiBclkSourceBusclk;

    i2s_config.channel = 0;

    i2s_config.mclk_source = kSaiMclkSourceSelect1;

    i2s_config.protocol = kSaiBusI2SType;

    i2s_config.slave_master = kSaiSlave;

    i2s_config.sync_mode = kSaiModeAsync;

    i2s_config.watermark = 1;

    i2s_config.dma_source = kDmaRequestMux0I2S0Rx;

    uint32_t i;

    for (i = 0; i < size; i++)

    {

        buffer[i] = 0;

    }

    status = SAI_DRV_RxInit(instance, &i2s_config, &i2s_state);

    if (status != kStatus_SAI_Success)

    {

        PRINTF("ERROR\r\n");

        while(1);

    }

    status = SAI_DRV_RxConfigDataFormat(instance, &i2s_data_format);

    if (status != kStatus_SAI_Success)

    {

        PRINTF("ERROR\r\n");

        while(1);

    }

    SAI_DRV_RxRegisterCallback(instance, &i2s_callback, NULL);

    status = SAI_DRV_ReceiveDataInt(instance, buffer, size);

    if (status != size)

    {

        PRINTF("ERROR\r\n");

        while(1);

    }

    while(1)

    {

        OSA_TimeDelay(100);

    }

}

int main()

{

    OSA_Init();

    hardware_init();

    uint8_t status;

    status = OSA_TaskCreate(primary_thread, (uint8_t*)"primary_thread", 10000L, NULL, 4L, NULL , false, NULL);

    if (kStatus_OSA_Success != status)

    {

        PRINTF("Error Creating thread \"primary_thread\" \r\n");

        while(1)

            ;

    }

    OSA_Start();

    return 0;

}

#endif

0 Kudos
1 Solution
529 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Sam,

There is no relationship between USB and I2S, except usb_host_init would use PTC9 as USB VBUS enable pin as default, which is has pin mux with I2S0_RX_BCLK, you may find configure_i2s_pins() in pun_mux,c also use this pin for I2S port, so maybe that is the cause, but I am not sure , would you please specify the platform you are using? if it is a custom board, please help to check if PTC9 is used for I2S interface.

Hope that helps,


Have a great day,
Kan

Freescale Technical Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
2 Replies
530 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Sam,

There is no relationship between USB and I2S, except usb_host_init would use PTC9 as USB VBUS enable pin as default, which is has pin mux with I2S0_RX_BCLK, you may find configure_i2s_pins() in pun_mux,c also use this pin for I2S port, so maybe that is the cause, but I am not sure , would you please specify the platform you are using? if it is a custom board, please help to check if PTC9 is used for I2S interface.

Hope that helps,


Have a great day,
Kan

Freescale Technical Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
529 Views
samtyler
Contributor I

Yes, you're right, thank you. I'm using the FRDM K-64F. As far as I can tell PTC9 is the only option for I2S0_RX_BCLK available on the board so I'll have to remap the VBUS pin.

Sam

0 Kudos