VS1053B + VS1053b / VS1063a WAV PCM Recorder Application

Writing software for systems that use VLSI Solution's devices as slave codecs to a host microcontroller.
Post Reply
kuprin_iv
User
Posts: 2
Joined: Fri 2020-10-09 20:41

VS1053B + VS1053b / VS1063a WAV PCM Recorder Application

Post by kuprin_iv » Fri 2020-10-09 20:54

Hello!
I use VS1053B codec with VS1053b / VS1063a WAV PCM Recorder Application plugin with microcontroller STM32F429. Sound records in wav-files and plays correctly, but i can't control monitoring volume, writing DAC_VOL register at address 0xC045 and mic gain, writing AICTRL1 register. I try read this registers after writing them and get correct values. And this functions works, when i start encoding with lower sampling frequency, for example 16 kHz.
My start encoding function:

Code: Select all

void startRecording(volatile recordingParams* rp)
{
	uint16_t mode_reg = 0, ramData = 0;
	uint16_t aictrl_reg3 = 0;

	mode_reg = readCommandRegister(MODE_REG);
	// reset SM_ADPCM bit
	mode_reg &= 0xEBFF;
	writeCommandRegister(MODE_REG, mode_reg);
	//initialize PCM recording differs for high sample frequencies, because another plugin is applied
	if(rp->sample_rate >= 24000){
		//set clock close to 55,3 MHz
		writeCommandRegister(CLOCKF_REG, 0xC000);
		//set SCI_BASS to 0
		writeCommandRegister(BASS_TREBLE_CONTROL_REG, 0);
		//disable any potential user application
		writeCommandRegister(AIADDR_REG, 0);
		//disable all interrupts except SCI interrupts
		ramData = 2;
		writeRAMData(0xC01A, &ramData, 1);
		//load plugin
		switch(rp->sample_rate){
			case 24000:
				if(rp->channelType == 2){ // mono, left channel
					loadPlugin(vs1053b_24k_l, 1542);
				}else if (rp->channelType == 3){ // mono, left channel
					loadPlugin(vs1053b_24k_r, 1538);
				}
				break;

			case 48000:
				if(rp->channelType == 2){ // mono, left channel
					loadPlugin(vs1053b_48k_l, 1567);
				}else if (rp->channelType == 3){ // mono, left channel
					loadPlugin(vs1053b_48k_r, 1567);
				}
				break;

			default:
				break;
		}
		//set AICTRL registers
		writeCommandRegister(AICTRL0_REG, 0);
		writeCommandRegister(AICTRL1_REG, rp->micGain);
		writeCommandRegister(AICTRL2_REG, rp->maxAutoGain);
		writeCommandRegister(AICTRL3_REG, 0);

		//set ADPCM bit, select input
		mode_reg |= 0x1800;
		writeCommandRegister(MODE_REG, mode_reg);

		// activate encoder
		writeCommandRegister(AIADDR_REG, 0x34);
		//wait at least 1 us
		HAL_Delay(1);
	}else{
		//set clock
		writeCommandRegister(CLOCKF_REG, 0x9800);
		//disable all interrupts except SCI interrupts
		ramData = 2;
		writeRAMData(0xC01A, &ramData, 1);

		aictrl_reg3 = ((rp->pcmMode & 0x01)<<2)|(rp->channelType & 0x03);
		//set AICTRL registers
		writeCommandRegister(AICTRL0_REG, rp->sample_rate);
		writeCommandRegister(AICTRL1_REG, rp->micGain);
		writeCommandRegister(AICTRL2_REG, rp->maxAutoGain);
		writeCommandRegister(AICTRL3_REG, aictrl_reg3);

		//set ADPCM bit, select input
		mode_reg |= 0x1800;
		writeCommandRegister(MODE_REG, mode_reg);

		//write patch
		loadPlugin(IMA_fix_plugin, 74);
	}
	//wait until DREQ pin is high
	while(!(GPIOD->IDR & GPIO_PIN_13)){} //wait while DREQ set to 1
}
Also, in reproduced the issue with 24 kHz encoding, that discussed in this topic: http://www.vsdsp-forum.com/phpbb/viewto ... =11&t=2581
Can you help me enable mic gain and monitoring control function, or correct my recording init function?

kuprin_iv
User
Posts: 2
Joined: Fri 2020-10-09 20:41

Re: VS1053B + VS1053b / VS1063a WAV PCM Recorder Application

Post by kuprin_iv » Yesterday 10:25

I got around this problem by abandoning the recording plugin and performing initialization on the datasheet with the plugin IMA fix

Post Reply