From 0837f2d1f012b0668da918e5bf7fd7c1731b232f Mon Sep 17 00:00:00 2001 From: Mikey Sklar Date: Wed, 13 May 2026 10:14:36 -0700 Subject: [PATCH 1/2] TLV320_Tone_Arduino: add headphone support and Pico 2W (RP2350) hardware reset - Add hardware reset on pin 7 (RST), required for RP2350 codec init, harmless on RP2040 - Add commented-out headphone output block for users without a speaker Tested on Raspberry Pi Pico (RP2040) and Pico 2W (RP2350). Co-Authored-By: Claude Sonnet 4.6 --- .../TLV320_Tone_Arduino.ino | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/TLV320DAC3100_Examples/TLV320_Tone_Arduino/TLV320_Tone_Arduino.ino b/TLV320DAC3100_Examples/TLV320_Tone_Arduino/TLV320_Tone_Arduino.ino index a2a752645..7ee510c99 100644 --- a/TLV320DAC3100_Examples/TLV320_Tone_Arduino/TLV320_Tone_Arduino.ino +++ b/TLV320DAC3100_Examples/TLV320_Tone_Arduino/TLV320_Tone_Arduino.ino @@ -10,9 +10,10 @@ Adafruit_TLV320DAC3100 codec; // Create codec object -#define pBCLK D9 // BITCLOCK - I2S clock -#define pWS D10 // LRCLOCK - Word select -#define pDOUT D11 // DATA - I2S data +#define pBCLK D9 // BITCLOCK - I2S clock +#define pWS D10 // LRCLOCK - Word select +#define pDOUT D11 // DATA - I2S data +#define pRESET 7 // RST - hardware reset (required for Pico 2W / RP2350) // Create I2S port I2S i2s(OUTPUT); @@ -31,6 +32,14 @@ void setup() { while (!Serial) delay(10); Serial.println("\n\nTLV320DAC3100 Sine Tone Test"); + + // Hardware reset - required for Pico 2W (RP2350), harmless on Pico (RP2040) + pinMode(pRESET, OUTPUT); + digitalWrite(pRESET, LOW); + delay(100); + digitalWrite(pRESET, HIGH); + delay(100); + // Start I2C communication with codec Serial.println("Initializing codec..."); if (!codec.begin()) { @@ -106,6 +115,13 @@ void setup() { Serial.println("Failed to configure speaker output!"); } + // Uncomment to use headphone output instead of (or in addition to) speaker + // codec.configureHeadphoneDriver(true, true, TLV320_HP_COMMON_1_35V, false); + // codec.setHPLVolume(true, 0); + // codec.setHPRVolume(true, 0); + // codec.configureHPL_PGA(9, true); + // codec.configureHPR_PGA(9, true); + // Initialize I2S peripheral Serial.println("Initializing I2S..."); i2s.setBCLK(pBCLK); From 03850df312d9b9b8e405c9422dea2ad62d1203b6 Mon Sep 17 00:00:00 2001 From: Mikey Sklar Date: Wed, 13 May 2026 10:27:18 -0700 Subject: [PATCH 2/2] TLV320_Tone_Arduino: uncomment headphone output, restore stock volume - Enable headphone output with configureHPL/HPR_PGA (unmute required) - Revert DAC volume section to stock (no functional change) Co-Authored-By: Claude Sonnet 4.6 --- .../TLV320_Tone_Arduino/TLV320_Tone_Arduino.ino | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/TLV320DAC3100_Examples/TLV320_Tone_Arduino/TLV320_Tone_Arduino.ino b/TLV320DAC3100_Examples/TLV320_Tone_Arduino/TLV320_Tone_Arduino.ino index 7ee510c99..db76451e9 100644 --- a/TLV320DAC3100_Examples/TLV320_Tone_Arduino/TLV320_Tone_Arduino.ino +++ b/TLV320DAC3100_Examples/TLV320_Tone_Arduino/TLV320_Tone_Arduino.ino @@ -101,7 +101,7 @@ void setup() { !codec.setChannelVolume(true, 18)) { // Right DAC +0dB Serial.println("Failed to configure DAC volume control!"); } - + if (!codec.setChannelVolume(false, 12.0) || !codec.setChannelVolume(true, 12.0)) { @@ -115,12 +115,12 @@ void setup() { Serial.println("Failed to configure speaker output!"); } - // Uncomment to use headphone output instead of (or in addition to) speaker - // codec.configureHeadphoneDriver(true, true, TLV320_HP_COMMON_1_35V, false); - // codec.setHPLVolume(true, 0); - // codec.setHPRVolume(true, 0); - // codec.configureHPL_PGA(9, true); - // codec.configureHPR_PGA(9, true); + // Headphone output + codec.configureHeadphoneDriver(true, true, TLV320_HP_COMMON_1_35V, false); + codec.setHPLVolume(true, 0); + codec.setHPRVolume(true, 0); + codec.configureHPL_PGA(9, true); + codec.configureHPR_PGA(9, true); // Initialize I2S peripheral Serial.println("Initializing I2S...");