Skip to main content
aturk.2
Associate II
September 30, 2022
Solved

hi im working on FDA903D AEK AUD D903V1 autodevkit, im trying to send information from an NXP MPCU5748G microcontroller through I2C AND I2S.

  • September 30, 2022
  • 2 replies
  • 4841 views

i have set enables 1,2,3 and 4 as 1100 which is address 2 , but for some reason the speaker is not open and voltage is not passing through it which means i cant move on and give orders through i2c registers, can you please explain what the reason might be?

    This topic has been closed for replies.
    Best answer by Max VIZZINI
    1. First install SPC5Studio https://www.st.com/en/development-tools/spc5-studio.html
    2. Download AutoDevKit library from www.st.com/autodevkitsw
    3. Install AutoDevKit on SPC5Studio.

    For point 3. please refer to paragraph 8.1 of User Manual UM2623

    https://www.st.com/resource/en/user_manual/um2623-how-to-assemble-and-use-the-autodevkit-adaptive-front-lighting-kits-stmicroelectronics.pdf

    or watch the following YouTube self learning video 1

    https://www.youtube.com/watch?v=WDp4XmmwEwc&list=PLnMKNibPkDnEju3j_qhe-MFK-NnwD_kuP

    If you watch all 8 videos of 10min each it will give you a basic understanding of

    how the environment works.

    Regards,

    AutoDevKit Team

    2 replies

    Max VIZZINI
    Technical Moderator
    September 30, 2022

    Dear Sir,

    As you can understand, it is not possible for us to help you debug the NXP microcontroller. I can only report the init procedure we use. For the configuration of the MCU peripherals you should consult with NXP.

    The Init() function for the FDA903D is the following (on our Microcontroller):

    // The following line reset the address signals

    pal_lld_clearpad(Enables_ARRAY[dev][0], Enables_ARRAY[dev][1]);     

    pal_lld_clearpad(Enables_ARRAY[dev][2], Enables_ARRAY[dev][3]);     

    pal_lld_clearpad(Enables_ARRAY[dev][4], Enables_ARRAY[dev][5]);    

    pal_lld_clearpad(Enables_ARRAY[dev][6], Enables_ARRAY[dev][7]);

    // We wait a period to stabilize the signals

    osalThreadDelayMilliseconds(500);

    //Enables address with combination 1100 0xE2

    pal_lld_setpad(Enables_ARRAY[dev][0], Enables_ARRAY[dev][1]);      //Enable 1 = 1

    pal_lld_setpad(Enables_ARRAY[dev][2], Enables_ARRAY[dev][3]);     //Enable 2 = 1

    pal_lld_clearpad(Enables_ARRAY[dev][4], Enables_ARRAY[dev][5]);  //Enable 3 = 0

    pal_lld_clearpad(Enables_ARRAY[dev][6], Enables_ARRAY[dev][7]);     //Enable 4 = 0

    // Initialize register with default value

    uint8_t data[15];

    // Init: Turn IB registers into application default setting

    data[0] = IB0_DEFAULT; // data[0] = 0x00;

      data[1] = IB1_DEFAULT; // data[1] = 0x00;

      data[2] = IB2_DEFAULT;  // data[2] = 0x00;

      data[3] = IB3_DEFAULT;  // data[3] = 0x38;

      data[4] = IB4_DEFAULT;  // data[4] = 0x00;

      data[5] = IB5_DEFAULT;  // data[5] = 0x00;

      data[6] = IB6_DEFAULT;  // data[6] = 0x00;

      data[7] = IB7_DEFAULT;  // data[7] = 0x00;

      data[8] = IB8_DEFAULT;  // data[8] = 0xC0;

      data[9] = IB9_DEFAULT;  // data[9] = 0x00;

      data[10] = IB10_DEFAULT;  // data[10] = 0x50;

      data[11] = IB11_DEFAULT;  // data[11] = 0x30;

      data[12] = IB12_DEFAULT;  // data[12] = 0x00;

      data[13] = IB13_DEFAULT;  // data[13] = 0x20;

      data[14] = IB14_DEFAULT;  // data[14] = 0x09;

    AEK_903D_Write_IB(dev, IB0, &data[0], 15); // IB14[0] = 1; FIRST bit

    The function to send the first message is:

    i2c_result_t AEK_903D_Write_IB(AEK_AUD_D903V1_DEVICE dev, uint8_t reg_addr, uint8_t * data, uint8_t size)

    {

    // Check address range

      if (reg_addr > FDA903D_IB_ADDR_MAX)

      {

        return I2C_ERROR_INVALID_ADDRESS;

      }

      if (size > 1)

      {

        reg_addr |= 0x80;    // Continues Write

      }

      return i2c_lld_write(AEK_AUD_D903V1_I2C_ARRAY_DRIVER[dev],(uint8_t)I2CAddress[dev], reg_addr, data, size);

    }

    I hope it helps!

    Best Regards,

    AutoDevKit Team

    aturk.2
    aturk.2Author
    Associate II
    October 3, 2022

    Mr. Max , if i give my enables 1100 without doing any other procedure, the speaker should open right?

    Also , do i need to reset the values of the enables and registers to 0?

    Max VIZZINI
    Technical Moderator
    October 3, 2022

    The Enables set the I2C address nothing to do with the speaker.

    Please follow the entire procedure include register reset to activate the I2C.

    Max VIZZINI
    Technical Moderator
    September 30, 2022

    The full code for our microcontroller SPC582B is available on AutoDevKit www.st.com/autodevkitsw

    aturk.2
    aturk.2Author
    Associate II
    October 10, 2022

    Mr max , i took the driver and inclluded it to my project, the code i wrote is like this:

    my functions:

    void AEK_903D_Init()

    {

    HAL_GPIO_WritePin(GPIOE, GPIO_PIN_8, GPIO_PIN_RESET);

    HAL_GPIO_WritePin(GPIOE, GPIO_PIN_10, GPIO_PIN_RESET);

    HAL_GPIO_WritePin(GPIOE, GPIO_PIN_12, GPIO_PIN_RESET);

    HAL_GPIO_WritePin(GPIOE, GPIO_PIN_14, GPIO_PIN_RESET);

    HAL_Delay(500);

    HAL_GPIO_WritePin(GPIOE, GPIO_PIN_8, GPIO_PIN_RESET);

    HAL_GPIO_WritePin(GPIOE, GPIO_PIN_10, GPIO_PIN_SET);

    HAL_GPIO_WritePin(GPIOE, GPIO_PIN_12, GPIO_PIN_RESET);

    HAL_GPIO_WritePin(GPIOE, GPIO_PIN_14, GPIO_PIN_RESET); // I2C adress is 0100 = 0xE0

    }

    uint16_t AEK_903D_SetDefaultRegisters()

    {

    HAL_StatusTypeDef status;

      uint8_t data[15];

      uint8_t play = 0B11100001;

      // Init: Turn IB registers into application default setting

    data[0] = IB0_DEFAULT; // data[0] = 0x00;

      data[1] = IB1_DEFAULT; // data[1] = 0x00;

      data[2] = IB2_DEFAULT; // data[2] = 0x00;

      data[3] = IB3_DEFAULT; // data[3] = 0x38;

      data[4] = IB4_DEFAULT; // data[4] = 0x00;

      data[5] = IB5_DEFAULT; // data[5] = 0x00;

      data[6] = IB6_DEFAULT; // data[6] = 0x00;

      data[7] = IB7_DEFAULT; // data[7] = 0x00;

      data[8] = IB8_DEFAULT; // data[8] = 0xC0;

      data[9] = IB9_DEFAULT; // data[9] = 0x00;

      data[10] = IB10_DEFAULT; // data[10] = 0x50;

      data[11] = IB11_DEFAULT; // data[11] = 0x30;

      data[12] = IB12_DEFAULT; // data[12] = 0x00;

      data[13] = IB13_DEFAULT; // data[13] = 0x20;

      data[14] = IB14_DEFAULT; // data[14] = 0x09;

      //return AEK_903D_Write_IB(dev, IB0, &data[0], 15); // IB14[0] = 1; FIRST bit

      status = HAL_I2C_Mem_Write(&hi2c1, 0xE0, IB8, 15, &play, 15, 100); // play is 11100001 which puts PWM on and plays

      if(HAL_OK == status)

      {

      HAL_GPIO_WritePin(GPIOG, GPIO_PIN_13, GPIO_PIN_SET);

      return 1;

      }

      return 0;

    }

    in my main:

    int main(void)

    {

     /* USER CODE BEGIN 1 */

    //findF_Out(1250);

    sample_dt = F_OUT/F_SAMPLE;

    sample_N = F_SAMPLE/F_OUT;

     /* USER CODE END 1 */

     /* MCU Configuration--------------------------------------------------------*/

     /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

     HAL_Init();

     /* USER CODE BEGIN Init */

     /* USER CODE END Init */

     /* Configure the system clock */

     SystemClock_Config();

     /* USER CODE BEGIN SysInit */

     /* USER CODE END SysInit */

     /* Initialize all configured peripherals */

     MX_GPIO_Init();

     MX_DMA_Init();

     MX_I2C1_Init();

     MX_I2S3_Init();

     MX_CAN1_Init();

     /* USER CODE BEGIN 2 */

     if( HAL_CAN_Start(&hcan1) != HAL_OK)

     {

     Error_Handler();

     }

    // CAN notification

    if(HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO0_MSG_PENDING) != HAL_OK)

    {

    Error_Handler();

    }

    sample_dt = F_OUT/F_SAMPLE;

    sample_N = F_SAMPLE/F_OUT;

     AEK_903D_Init();

     AEK_903D_SetDefaultRegisters();

     for(uint16_t i=0; i<sample_N; i++){

     mySinVal = sinf(i*2*PI*sample_dt);

     dataI2S[i*2]=(mySinVal+0)*8000;

     dataI2S[i*2+1]=(mySinVal+0)*8000;

     }

     HAL_I2S_Transmit_DMA(&hi2s3, (uint16_t *)dataI2S, sample_N*2);

     HAL_DAC_Start(&hdac, DAC1_CHANNEL_1);

     HAL_TIM_Base_Start_IT(&htim2);

    QUESTION 1: is the function that sends play correct?

    QUESTION 2: i have error in the last two lines.

    0693W00000UnixtQAB.png 

    Max VIZZINI
    Technical Moderator
    October 10, 2022

    Dear Sir,

    Unfortunately, I am not familiar with STM32 peripherals therefore I cannot help you with that.

    We only support Automotive microcontrollers like SPC58.

    Thank you in advance for your understanding.

    Best Regards,

    AutoDevKit Team