From a2fb4a6af8d845f1cd6b2d33909a1d3f3081a336 Mon Sep 17 00:00:00 2001 From: unicod Date: Tue, 10 Mar 2026 23:33:51 +0100 Subject: [PATCH] ADC gain: PGA setting test --- Core/Src/main.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Core/Src/main.c b/Core/Src/main.c index df45e67..05f7487 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -444,6 +444,7 @@ int main(void) int16_t ch = Uart5_GetByte(); if (ch != -1) { // if data received char c = ch; + static uint8_t PGA = 64; if (c == 'a') { printf("I2S RX buf:\n"); for (size_t i = 0; i < I2S2_RXDMA_BUF_SAMPLE_CNT; i++) { @@ -453,6 +454,22 @@ int main(void) DumpI2SBufCnt = 512; // dump next 512 samples from I2S buffer in Proc_I2S_Buffer function } else if (c == 'd') { TLV320_AIC3204_DumpRegs(); + }else if (c == 'u') { + if (PGA < 127-8) { + PGA += 8; + TlvWriteReg(CODEC_A, TLV_PAGE_0, 15, PGA); // PGA_L + TlvWriteReg(CODEC_A, TLV_PAGE_0, 16, PGA); // PGA_R + printf("PGA: %u\n", PGA); + } + }else if (c == 'j') { + if (PGA >= 8) { + PGA -= 8; + TlvWriteReg(CODEC_A, TLV_PAGE_0, 15, PGA); // PGA_L + TlvWriteReg(CODEC_A, TLV_PAGE_0, 16, PGA); // PGA_R + printf("PGA: %u\n", PGA); + } + }else if (c == 'f') { + TlvWriteReg(CODEC_A, TLV_PAGE_0, 12, 0xF0); // Enable ADC high-pass filter } if (isdigit(c)) { ChSel = c - '0';