[Learn, Build & Win] Building a Standalone Offline Music Player Using the MAX32655FTHR

Building a Standalone Offline Music Player Using the MAX32655FTHR — Day 1

Introduction

For this project, I wanted to build a compact, standalone music player rather than another embedded device that depends on a smartphone or an internet connection for its primary functionality.

A huge thanks to Circuit Digest and Digikey for giving me this opportunity

The idea was to combine embedded hardware, audio processing, removable storage, a custom graphical interface, physical controls, and a 3D-printed enclosure into one portable device.

The result is a Japanese Sakura-inspired music player designed around the MAX32655FTHR
development board from Analog Devices
.

The central requirement is straightforward: store music locally on a microSD card, browse the available tracks, select a song using physical controls, and listen through a wired headphone output. However, implementing this requires several subsystems to work together correctly.

System architecture

The project is built around the following hardware:

  • Controller: Analog Devices MAX32655FTHR development board.

  • Display: 1.9-inch, 170 × 320 ST7789 TFT module connected over SPI.

  • Storage: Onboard microSD card interface for locally stored music.

  • Audio: Onboard audio codec and 3.5 mm headphone output.

  • User input: Physical Select, Left, and Right navigation controls.

  • Mechanical design: Custom 3D-printed enclosure designed around the board and display.

The MAX32655FTHR was an interesting choice because it brings several useful capabilities together on one development platform. Instead of building a separate audio subsystem and adding a collection of external modules immediately, I could begin by investigating what the board already provides.

Design philosophy

I wanted this device to feel like a dedicated piece of hardware.

That means the user should be able to navigate the music library and control playback without needing to unlock a phone, open an application, or establish an internet connection.

The display uses a Japanese Sakura-inspired visual identity, with a compact layout designed specifically for the small screen. The intention is to keep the interface visually distinctive while remaining readable and practical.

Bluetooth Low Energy is available on the controller, but wireless audio streaming is not part of the initial design. The primary audio path is through wired headphones.

What makes the project interesting?

The challenge is not simply connecting a display or getting a microcontroller to play a file. It is integrating storage, display rendering, input handling, and audio output into one responsive embedded application.

Each subsystem has different timing and resource requirements. Display updates must not interrupt audio playback, file access must be reliable, and physical controls must remain responsive while the device is operating.

Over this seven-part series, I’ll discuss the hardware architecture, display integration, mechanical design, navigation, storage, audio pipeline, and the final assembled device.

#AnalogDevices #MAX32655FTHR #EmbeddedSystems #AudioElectronics #DigiKey

hi this is an excellent start guys

Sakura Music Player : Firmware Setup, Programmer Configuration and Hardware Interface

The second stage focused on establishing the firmware development workflow and interfacing the display and navigation controls with the MAX32655FTHR.

1. Development Environment and Programming Interface

I used Visual Studio Code to organise and develop the firmware in C, separating the application into modules such as main.c, display.c, audio_player.c and font8x12.h. This modular structure keeps display rendering, application control and audio playback logic separate, making debugging and future modifications easier.

The MAX32655FTHR integrates a MAX32625-based DAPLink programming and debugging interface. Connecting the board to the host PC through its USB programming interface provides a route to flash firmware onto the MAX32655 Arm Cortex-M4F core and debug the application without requiring a separate external programmer. The board uses a 100 MHz Cortex-M4F with 512 KB flash and 128 KB SRAM, alongside onboard audio and storage peripherals. Official board documentation

2. ST7789 Display Interface

The 170 × 320 ST7789 TFT is connected through SPI, using separate GPIO signals for chip select, data/command selection and reset. The firmware configures SPI1 and controls the display signals directly. The DC line distinguishes display commands from pixel or parameter data, while CS selects the display and RST provides hardware reset control.

ST7789 Display Pin MAX32655FTHR Connection Purpose
GND GND Common ground reference
VCC 3.3 V supply Display power
SCL SPI1 SCK Serial clock
SDA SPI1 MOSI Display data
CS P0.20 Chip select
DC P1.8 Command/data selection
RES P1.9 Hardware reset
BLK 3.3 V, subject to module specification Backlight control/power

The display’s SCL and SDA labels refer to SPI clock and data on this module, not I²C. Confirm the board-header mapping and display-module voltage requirements before reproducing the wiring.

3. Navigation Switch Interface

A three-direction navigation switch (commonly found in cheap Bluetooth speaker modules) provides the user input for the player. Each switch contact is read through a GPIO input configured with a pull-up; pressing a key connects its input to ground, producing an active-low signal. Firmware must debounce the inputs to prevent contact bounce from generating repeated navigation events.


Switch Connection
MAX32655FTHR GPIO Function
Common (COM) GND Ground reference
SELECT P2.0 Select/play-pause action
LEFT P2.1 Previous-track navigation
RIGHT P2.2 Next-track navigation

4. Firmware Organisation and Bring-Up

The display module handles initialization, command/data transmission, reset sequencing and UI drawing. The font header stores character bitmap data, while the main application coordinates user input and player state. The audio module is kept separate so that playback logic can be developed without coupling it to display rendering.

The initial bring-up priority was to verify USB programming/debug access, confirm the GPIO and SPI configuration, and establish reliable communication with the display before integrating the complete music-player interface. The MAX32655FTHR also provides onboard microSD storage and a low-power stereo audio codec, which form the hardware foundation for offline playback. MAX32655FTHR hardware overview

Next update: Initialising the ST7789, rendering the Sakura-themed interface and implementing display updates efficiently.

Circuit Digest Resources
The above page has all the clear instructions to setup the board and also proper pinouts and configuration

problems faced : simultaneous display rendering and SD card reading has some conflict
currently trying : state machine or RTOS based approach

Enclosure Design and 3D Modelling in Fusion 360

With the electronics and display interface established, the next step was designing a custom enclosure to integrate the hardware into a compact, handheld device. I used Autodesk Fusion 360 to model the enclosure around the actual component layout, focusing on fit, accessibility and ease of assembly.

1. Enclosure Modelling

The design was developed as two separate parts: the main enclosure and a removable front cover. The main body provides space for the MAX32655FTHR development board, display wiring and internal components, while the cover has a dedicated opening for the TFT display.

Key modelling features included:

  • Base geometry: A rounded-rectangle profile was used to establish the enclosure footprint, followed by extrusion to create the housing walls.

  • Internal mounting features: Raised bosses and support points were incorporated to position and secure the electronics.

  • Display aperture: A rectangular cut-out was modelled to expose the active display area while keeping the surrounding edges supported.

  • Connector access: Openings were included for external connections, including the USB cable and audio interface.

  • Separate cover: A second component was modelled with a matching perimeter and fastening features to allow access to the internal electronics.

A cute touch :wink: :

2. Design for Assembly and 3D Printing

The enclosure was modelled with the physical arrangement of the board, display and wiring in mind. Internal clearance is important because jumper wires and connectors occupy additional volume beyond the PCB outlines. Mounting positions, wall thickness, corner radii and cover alignment also affect the final fit and assembly.

Fusion 360’s sketch-based and parametric solid-modelling workflow made it possible to refine individual features without rebuilding the entire model. Tools such as Sketch, Extrude, Cut, Fillet and Hole are particularly useful for creating this type of enclosure.

3D printing Files here :

case.rar (204.6 KB)

3. From CAD Model to Physical Hardware

The screenshots show the enclosure geometry at different viewing angles, including the internal supports, side openings and separate cover. The completed assembly was designed to house the electronics while maintaining access to the display and external connections.

The goal was not simply to create a protective shell, but to develop a mechanically organised enclosure that brings the electronic and user-interface components together into a single portable device.

Next update: Display integration, the Sakura-themed user interface and bringing the physical controls together with the firmware.

Finally printed the enclosure I designed in Fusion 360. Had to make sure the display and rotary control fit properly. Still have a few things to improve, but happy with how it turned out!

Software Implementation (Part 1/6): Firmware Setup and Flashing

After completing the hardware and enclosure, I moved on to firmware development for the MAX32655FTHR-based Sakura offline music player.

I used Visual Studio Code, Analog Devices’ MaximSDK, and a GNU Arm toolchain. The firmware is written in C and divided into modules for the application logic, ST7789 display, microSD interface, and audio playback.

The first challenge: firmware flashing

The standard OpenOCD flashing workflow was unreliable during development. Flash operations repeatedly timed out, and some attempts took several minutes to complete. Increasing the SWD adapter speed did not resolve the issue.

Rather than continuing to troubleshoot the same workflow, I investigated the MAX32655’s internal Flash Controller (FLC) and explored executing a small programming routine directly from SRAM.

Using SRAM as a flashing workspace

The approach involved two components:

  • A small C routine, scratch_flasher.c, compiled into scratch_flasher.bin and loaded into SRAM.

  • A Python utility, burn_full_firmware.py, that communicates with OpenOCD through its TCL interface and transfers firmware data in blocks.

The documented SRAM addresses were:

#define FLASHER_ADDR  0x20000000
#define FLASH_BUF_ADDR 0x20001000
#define FLASH_BLOCK_SIZE (16 * 1024)

The first address is used for the flashing routine, while the second is used as the firmware staging buffer. The utility coordinates the transfer and invokes the SRAM routine to program the internal flash through the FLC.

The basic sequence is:

  1. Connect to the MCU through OpenOCD and halt the target.

  2. Erase the required flash region.

  3. Load the flashing routine into SRAM.

  4. Transfer firmware blocks into the staging buffer.

  5. Program the internal flash and verify the result.

Result

According to the development record, a firmware image of approximately 158 KB was programmed and verified in about 5.72 seconds. This made repeated firmware iterations significantly faster.

The main lesson for me was that debugging an embedded system also means examining the development tools themselves. When a default flashing workflow becomes a bottleneck, understanding the MCU’s memory map and flash-controller architecture can open up alternative approaches.

Next: Implementing the ST7789 display driver and managing framebuffer memory on a microcontroller with limited SRAM.

Software Implementation (Part 2/6): Driving the ST7789 Display with Limited SRAM

The next step in my firmware development was bringing up the 1.9-inch ST7789 display. The display is 170 × 320 pixels, and I wanted the interface to remain responsive while the microcontroller handled audio playback, SD card access and BLE.

The challenge wasn’t just drawing pixels. It was doing so without consuming too much of the MAX32655’s 128 KB of SRAM.

1. Initialising the display over SPI

I used the MAX32655’s hardware SPI1 peripheral, configured for 24 MHz. The display uses separate control signals for chip select, data/command selection and reset.

Signal MAX32655 pin
SPI clock (SCK) P0.23
SPI data (MOSI) P0.21
Chip select (CS) P0.20
Data/command (DC) P1.8
Reset (RST) P1.9

The ST7789 uses commands to configure the panel and define the region where pixel data should be written. For example, CASET (0x2A) sets the column range, RASET (0x2B) sets the row range, and RAMWR (0x2C) begins writing pixel data.

A simplified command/data interface looks like this:

#define ST7789_CASET  0x2A
#define ST7789_RASET  0x2B
#define ST7789_RAMWR  0x2C

static void display_write_command(uint8_t cmd)
{
    // Select command mode
    // Transmit cmd over SPI
}

static void display_write_data(uint8_t data)
{
    // Select data mode
    // Transmit data over SPI
}

These functions illustrate the driver structure; the actual implementation also needs GPIO control, SPI transactions and error handling. The panel’s column offset must also be accounted for when setting the address window.

2. Why I avoided a full framebuffer

A full-screen RGB565 framebuffer would require:

#define DISPLAY_WIDTH   170
#define DISPLAY_HEIGHT  320
#define BYTES_PER_PIXEL 2

#define FRAMEBUFFER_SIZE \
    (DISPLAY_WIDTH * DISPLAY_HEIGHT * BYTES_PER_PIXEL)

That works out to 108,800 bytes, or approximately 106.25 KiB. On a microcontroller with 128 KiB of SRAM, that leaves too little room for the rest of the application once audio buffers, filesystem operations and BLE are taken into account.

Instead, I implemented a stripe-based rendering approach.

3. Rendering the display in stripes

Rather than storing every pixel at once, the renderer processes 16 scanlines at a time.

#define DISPLAY_STRIPE_H  16

static uint16_t stripe_buf[
    DISPLAY_WIDTH * DISPLAY_STRIPE_H
];

The buffer occupies:

170 \\times 16 \\times 2 = 5440\\text{ bytes}

That’s only 5.44 KB, compared with 108.8 KB for a full framebuffer.

The rendering process is straightforward:

  1. Draw the current stripe into stripe_buf.

  2. Set the display’s column and row address window.

  3. Send the pixel data over SPI.

  4. Move to the next stripe and repeat.

This lets the display update without reserving a complete screen-sized buffer in RAM.

4. Updating only the parts that change

I also separated different UI updates instead of treating every button press or playback event as a reason to redraw the entire screen.

For example, moving through the playlist can update the selection area, while a volume change can refresh the volume overlay. The playback timeline can be updated independently as the track progresses.

This is particularly useful in an audio player because the display is only one of several subsystems competing for processing time and memory.

What I learned

The biggest takeaway was that display resolution doesn’t have to dictate framebuffer memory usage. A carefully designed rendering pipeline can trade additional rendering passes for a much smaller memory footprint.

That trade-off was important on the MAX32655, where the same SRAM also supports the audio and communication subsystems.

Next: Bringing up the MAX9867 audio codec, enabling its power supply and getting the clocking right for audio playback.

Sakura Music Player — Software Implementation (Part 3/6): Bringing Up the MAX9867 Audio Codec

After getting the display working, I moved on to the most important part of the project: audio playback.

The audio subsystem is built around the MAX9867 codec, interfaced with the MAX32655FTHR through I2C and I2S. Getting the codec to respond was not as straightforward as I initially expected. I encountered issues with its power supply, master clock and sample-rate configuration.

1. Understanding the audio connections

The MAX9867 uses I2C for register configuration and I2S for digital audio transfer.

Signal MAX32655 pin
I2C1 SCL P0.16
I2C1 SDA P0.17
I2S SCK P0.20
I2S WS P0.21
I2S SD P0.22
Master clock enable P0.14

The external active oscillator provides a 12.288 MHz master clock.

2. The codec was not responding over I2C

Initially, the MAX9867 did not acknowledge I2C transactions. Reading its revision ID register (0xFF) returned an error instead of the expected 0x42.

I first suspected an I2C configuration issue. However, checking the codec supply revealed the actual problem: its 1.8 V audio supply was controlled by the MAX20303 PMIC, and the BUCK2 regulator was disabled by default.

I implemented a power-up sequence before initialising the codec:

uint8_t cmd_data[4] = {
    0x00, 0x01, 0x14, 0x00
};

// Configure BUCK2 output
pmic_write_buf(0x0F, cmd_data, 4);

// Enable BUCK2
pmic_write_reg(0x17, 0x3A);

MXC_Delay(MXC_DELAY_MSEC(10));

After enabling the rail, the codec started responding over I2C and returned revision ID 0x42.

This was a useful reminder that an I2C peripheral can appear completely unresponsive when its power rail has not been enabled.

3. Enabling the master clock

The next issue was that I2C communication worked, but there was still no audio output.

The MAX9867 required the external 12.288 MHz master clock. On this board, the oscillator enable signal is connected to GPIO P0.14.

I added the following step during audio initialisation:

// Enable the external 12.288 MHz oscillator
MXC_GPIO_OutSet(MXC_GPIO0, MXC_GPIO_PIN_14);

MXC_Delay(MXC_DELAY_MSEC(30));

The delay allows the oscillator to stabilise before the codec and I2S interface are configured.

4. A sample-rate issue: 48 kHz worked, but 44.1 kHz did not

During testing, the built-in 48 kHz test tone played correctly, but 44.1 kHz MP3 tracks remained silent.

The problem was related to the MAX9867 clock configuration. The PLL enable bit in register 0x06 (CLK_HIGH) had been cleared during a code change.

The corrected configuration was:

uint8_t clk_high =
    MAX9867_PLL | ((ni >> 8) & 0x7F);

Here, MAX9867_PLL is 0x80. Restoring this bit enabled the codec’s PLL configuration required for the 44.1 kHz playback path.

Result

After correcting the PMIC power sequence, enabling the external oscillator and restoring the PLL configuration, the codec could be brought up for the intended audio playback path.

The important lesson was that audio debugging is not limited to checking the I2S data line. Power sequencing, master-clock availability and codec register configuration all need to be verified.

Sakura Music Player — Software Implementation (Part 4/6): microSD, FatFS and Eliminating Playback Noise

With the display and audio codec configured, the next step was implementing music storage and file access.

The player uses a microSD card to store MP3 and WAV files. I interfaced the card through SPI0 and used FatFS to handle the FAT32 filesystem.

1. microSD interface configuration

The microSD interface uses the following MAX32655 pins:

Signal MAX32655 pin
SPI0 SCK P0.7
SPI0 MOSI P0.5
SPI0 MISO P0.6
Chip select P0.4
Card detect P0.12
Socket power enable P0.15

One detail worth mentioning is that the SD card socket power is controlled by the MCU. The firmware must enable the socket supply before attempting to initialise the card.

The basic power-up sequence is:

// Enable microSD socket power
MXC_GPIO_OutSet(MXC_GPIO0, MXC_GPIO_PIN_15);

// Allow the supply to stabilise
MXC_Delay(MXC_DELAY_MSEC(50));

// Initialise SPI and mount the filesystem

FatFS handles filesystem operations, allowing the application to open files, read directory entries and retrieve audio data without implementing FAT32 parsing manually.

2. Reading audio files

The firmware uses FatFS file operations to access the selected track.

A simplified example of reading audio data is:

FIL audio_file;
UINT bytes_read;

FRESULT result;

result = f_open(
    &audio_file,
    "music/song.mp3",
    FA_READ
);

if (result == FR_OK)
{
    f_read(
        &audio_file,
        audio_buffer,
        sizeof(audio_buffer),
        &bytes_read
    );
}

The actual playback implementation maintains an input buffer for MP3 data. The decoder consumes compressed audio from this buffer and produces PCM samples for the audio output pipeline.

3. An unexpected problem: rhythmic tapping in the headphones

During MP3 playback, I noticed a repetitive tapping sound through the headphones.

At first, I suspected the audio codec, I2S transfer or power supply. However, the built-in sine-wave test tone played without this noise.

That observation helped narrow down the problem.

I then compared the tapping frequency with the MP3 frame rate. For a typical MPEG audio frame containing 1152 samples at 44.1 kHz:

f\_{\\text{frame}} = \\frac{44100}{1152}
f\_{\\text{frame}} \\approx 38.28\\text{ Hz}

The timing was almost identical to the noise I was hearing.

The original implementation was replenishing the compressed input buffer too frequently, causing repeated microSD SPI reads during playback.

4. Changing the buffer replenishment strategy

Instead of reading small amounts of data frequently, I changed the logic to refill the input buffer in larger chunks.

The revised approach was:

if (!eof && bytes_in < 4096)
{
    uint32_t space = MP3_IN_CHUNK - bytes_in;

    f_read(
        &g_file,
        g_mp3_in + bytes_in,
        space,
        &br
    );

    bytes_in += br;
}

The important change is the threshold:

bytes_in < 4096

Rather than performing a filesystem read for every decoded MP3 frame, the firmware waits until the buffered data falls below this threshold and then performs a larger read.

The development record describes refilling approximately 12 KB at a time.

5. Why this helped

SPI activity produces switching currents and can introduce electrical noise through supply and ground paths. On a compact board where digital storage signals and sensitive analogue audio circuitry are physically close, this can become noticeable.

Reducing the frequency of SD-card transactions reduced the repetitive interference observed during playback.

After the buffering change, the rhythmic tapping disappeared during the reported playback test.

Result

The microSD subsystem was integrated with FatFS, and the audio application could access MP3 and WAV files from the card.

The biggest lesson from this issue was that buffer design affects more than just performance. In mixed-signal embedded systems, the timing and frequency of digital peripheral activity can also influence analogue audio quality.

Part 5: Real-Time MP3 Decoding & I2S DMA Streaming

With the display, audio codec and microSD interface working, the next challenge was getting decoded audio to the headphones continuously without interruptions.

I integrated minimp3 to decode MP3 frames on the MAX32655 Cortex-M4F. The decoded PCM samples are then transferred to the MAX9867 through the I2S interface.

Audio Pipeline

The playback pipeline follows this sequence:

  1. Read compressed MP3 data from the microSD card using FatFS.

  2. Decode MP3 frames using minimp3.

  3. Store the resulting PCM samples in alternating audio buffers.

  4. Transfer PCM data to the MAX9867 using I2S and DMA.

  5. Switch buffers after each completed DMA transfer.

Ping-Pong DMA Buffering

I used a two-buffer approach so that the audio data could be prepared and transmitted in alternating buffers.

While one buffer is being transmitted, the next buffer can be prepared. This helps maintain a continuous audio stream without requiring the CPU to manually transfer every sample.

During testing, I also encountered an issue where the DMA auto-reload approach did not trigger the expected completion flow reliably. I reverted to a synchronous ping-pong transfer pattern, using the DMA completion flag to coordinate buffer switching.

if (dma_running) {
    while (!g_tx_done &&
           g_state != AUDIO_STATE_STOPPED &&
           !g_change_requested) {
        wsfOsDispatcher();
        PlayerApp_ProcessEvents();
    }
}

g_tx_done = 0;
play_sel = buf_sel;

MXC_DMA_ReleaseChannel(0);
MXC_I2S_TXDMAConfig(g_pcm_buf[play_sel], pcm_bytes);

dma_running = true;
buf_sel ^= 1;

Result

After correcting the DMA flow and restoring the codec PLL configuration, MP3 playback worked in real time. The playback timeline advanced correctly, and pause/resume and track switching worked as expected.

This was an important milestone: the MAX32655 was now decoding compressed audio and streaming PCM data to a dedicated audio codec.

Part 6: Audio Quality, Power Management & Final Integration

Getting audio playback working was only half the job. I wanted the player to reproduce music properly, manage power efficiently and support wireless control.

1. Solving the Missing Vocals Problem

During testing, I noticed something unusual: background instruments were audible, but the lead vocals in certain stereo tracks were almost completely missing.

The issue was related to the headphone output configuration.

The MAX32655FTHR uses a capless headphone output arrangement, but the MAX9867 had initially been configured for single-ended operation. This caused a channel-difference effect in the output, cancelling much of the centred audio content.

I corrected the headphone configuration to Stereo No-Cap Clickless Mode (Mode 2) and changed the digital filter register 0x0A to 0x00.

WR_REG(
    MAX9867_16_MODE,
    MAX9867_STEREO_NOCAP_CLICKLESS << MAX9867_HPMODE_POS
);

WR_REG(0x0A, 0x00);

After this change, the vocals and full stereo content were restored.

2. Low-Power Standby and Wake-Up

I also implemented a power-off option using the MAX32655 low-power standby mode.

An initial attempt using Backup Mode prevented the physical buttons from waking the device. I switched to Standby Mode and configured GPIO wake-up interrupts.

MXC_LP_EnterStandbyMode();

A button press wakes the controller, after which the system performs a reset and starts the player again.

3. Bluetooth Low Energy Control

For wireless control, I integrated the Cordio BLE stack and created a custom GATT service named Sakura-Player.

The service supports commands for:

  • PLAY and PAUSE

  • STOP

  • NEXT and PREV

  • TRACK selection

  • Volume control

This allows basic playback control without needing to interact directly with the device.

Final Result

The Sakura Audio Player brings together MP3/WAV playback, microSD storage, I2S audio streaming, a custom display interface, physical controls, BLE remote control and low-power standby.

Completing this project involved much more than connecting components. Debugging clock configuration, DMA transfers, audio output modes and power-state behaviour taught me a lot about building a complete embedded hardware product.

Project Links

YouTube :

GitHub Repository:

This concludes my six-part software implementation series for the Sakura Audio Player. Thank you for following the development journey!