Using TDA1543 I2S DAC with the LPC54114 board

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

Using TDA1543 I2S DAC with the LPC54114 board

Using TDA1543 I2S DAC with the LPC54114 board

This paper describes using a simple audio DAC (Digital to Analog Converter) with the LPC54114 board. As the processor offers hardware I2S interface, TDA1543, a widely available low-cost 16-bit I2S DAC, is used. This tutorial describes the steps of connecting it and preparing a code for using TDA1543 in your application with leveraging MCUXpresso tools and SDK.

Prerequisites

  1. MCUXpresso IDE 11.3
  2. MCUXpresso SDK for LPCXpresso54114 version 2.9.x (use https://mcuxpresso.nxp.com)
  3. For testing on hardware: LPCXpresso54114 board, TDA1543, and related parts (see below)

Hardware

TDA1543 is a 16-bit DAC with stereo output. It is available in an 8-pin DIP package with 3 digital input signals. It can operate with a minimum of external parts.

The following diagram shows a simple testing circuit used for this project to get an analog audio line output. This schematic can be easily wired using a breadboard.

Ana_37-1632315165421.png

Figure 1. Schematic of an elementary audio output DAC using TDA1543

Connection and pin configuration

The DAC uses the standard I2S interface which is a serial bus that consists of 3 signals: Clocks (in the nomenclature of our MCU it is the SCK signal), WS (Word select – indicating left or right channel), and DATA (serial data synchronized by the clock signal).

MCUXpresso Config Tools provide the Pins tool that can be leveraged for finding appropriate pins for the connection and routing them.

Steps:

1. Create a project for the LPCXpresso54114 board. If you need, you can find detailed instructions in this video. (https://www.nxp.com/design/training/basic-application-development-using-mcuxpresso-ide-and-mcuxpress...)

Hint: Ensure you select the appropriate board: 

Ana_38-1632315165528.png

2. Open the Pins tool. You can use the tools' Menu button in the Project panel: Ana_39-1632315165563.png

        NOTE:

Ensure you have selected the appropriate project when multiple projects are in the workspace.

3. Open the Peripheral signals view and unfold Flexcom7

         NOTE:

LPC 54114 MCU provides 8 instances of the Flexcomm communication peripheral that can be flexibly set for UART, SPI, I2C, but only Flexcomm6 and Flexcomm7 provide I2S interface. This tutorial uses Flexcomm7.

 Ana_40-1632315165596.png

       NOTE:

I2S signals are marked red. FlexComm5 (and lower) do not offer I2S signals.

4. Check the RXD_SDA_MOSI_DATA pin. In the dialog for routing, select which pin you would like to route the signal to. This tutorial uses pin 27

Tip: Find which expansion header connector and pin the processor pin is connected to in the tooltip of each pin:

 Ana_41-1632315165631.png

5. Repeat steps 3 and 4 for SCK and WS signals.

  • SCK – pin 26 (connected to J1[14])
  •  WS – pin 28 (connected to J1[12] and J9[6])

6. In the Routing details view, set the mode of all signals to Inactive (it disables internal pull-up).Ana_42-1632315165654.png

Configuring I2S in the Peripherals tool

Using the Peripherals tool, generate the initialization code for the Flexcomm I2S SDK driver that is used for communication with TDA1543.

Steps

7. In the Peripherals tool, open the Peripherals view and check Flexcomm7Ana_43-1632315165675.png

8. Select the I2S configuration component (category Peripheral driver).
Ana_44-1632315165708.png

9. The Problems view shows an error.  The FLEXCOMM driver is not present in the project. Right-click the error and select the action Add SDK component "FLEXCOMM Driver" into the project

Ana_59-1632317199789.png

In the shown SDK Component Management dialog box, confirm the addition of the files by clicking the Yes button.

10. In the added configuration component, set up the following items:

  • The Custom name checkbox is checked,  the Name: ‘CODEC’
  • Mode: Transfer (Note: Transfer mode is easy to use and provides asynchronous operation)
  • Sample rate: 24000 Hz
  • Transfer Configuration / Transfer functions setting / Buffer size in bytes: 32

         Ana_46-1632315165772.png

11. The Bit clock source frequency shows an error as the clocks of Flexcom7 are not enabled (inactive).          

Right-click the “bulb” icon offering possible fixes for the problem. Select the error message FXCOM7 clock is inactive and select the action Show problem in BOARD_BootClockHSRUN, which is the name of the functional group in the Clocks tool.

Ana_60-1632317271546.png

It opens the Clocks tool and highlights the FXCOMCLK7 clock output related to                             Flexcomm7:

   Ana_61-1632317297125.png

Configuring clocks

For correct communication, enable and configure clocks for the Flexcomm7 interface.

Steps

12. In the Path Details view (for FXCOM7 clock), set the FXCOM7 clock select to FRG clock, the output of

  Ana_49-1632315165824.png

         NOTE:

FRG is a Fractional Rate Generator allowing to provide non-integer ratios for clock frequencies.

13. Set the FRG clock select to FRO 12.

 Ana_50-1632315165843.png           

The clock path and frequencies are automatically updated.

14. Switch back to the Peripherals tool using the icon in the toolbar.

 Ana_51-1632315165846.png

15. The bit clock source frequency is now 12000000 Hz and it shows a warning because it does not match a value suitable for producing the required bit clock.

Ana_52-1632315165867.png

The nearest bit clock source frequencies show potential suitable values. Copy the first one            (11520000) to the clipboard and switch back to the Clocks tool.

16. Paste the value into the FXCOM7 clock value column and add ‘Hz’ units; otherwise, it is treated as currently used MHz.

  Ana_53-1632315165873.png

17. An error is reported. The Clocks tool cannot satisfy the requirement, so change the accuracy to a higher value.
Set it to 0.5 (which corresponds to 0.5 %):

Ana_54-1632315165876.png

Now the requirement is satisfied (producing 11.54 instead of 11.52 MHz):

Ana_55-1632315165879.png

Code

18. Update the generated code into the project by using the Update Code button. Ana_56-1632315165893.png

Confirm the update by clicking OK in the shown dialog.

19. Add the code into the main module (stored in the Sources folder of the MCUXpresso IDE project):

/* TODO: insert other definitions and declarations here. */
#define BUF_SIZE 32

// Example wave data for transfer, odd numbers are left channel, even numbers are
right channel
const uint16_t wave[32] = {
                     0,2000,4000,6000,8000,10000,12000,14000,
                     16000,18000,20000,22000,24000,26000,28000,30000,
};

// I2S callback function

volatile void CodecTx(I2S_Type *base, i2s_handle_t *handle, status_t
completionStatus, void *userData)
{
    /* Enqueue the same original s_Buffer all over again */
    //i2s_transfer_t *transfer = (i2s_transfer_t *)userData;
    I2S_TxTransferNonBlocking(base, handle, CODEC_Tx_Transfer);
}

Add the following code after the existing hello world PRINTF:

        PRINTF("Hello World\n");
        // prepare data into the buffer
        memcpy(CODEC_Tx_Buffer, wave, 32);
       // Start transfer
       I2S_TxTransferNonBlocking(CODEC_PERIPHERAL, &CODEC_Tx_handle,
CODEC_Tx_Transfer);

Testing on hardware

You can test the application on the LPC54114 evaluation board with a connected DAC chip.

Ana_57-1632315167494.png

Figure 2. DAC circuit wired with the evaluation board

The output checked using the sound-card input of a PC has the following result. It corresponds to the expectations:

Ana_58-1632315167505.png

Figure 3. Waveform measured at the output of the circuit

 

No ratings
Version history
Last update:
‎09-22-2021 10:28 AM
Updated by:
NXP Employee