VS1063 ADMixer config and patch issue.

Writing software for systems that use VLSI Solution's devices as slave codecs to a host microcontroller.
Post Reply
Dman
User
Posts: 3
Joined: Tue 2022-07-05 17:44

VS1063 ADMixer config and patch issue.

Post by Dman »

Hi,
A quick overview of the hardware, VS1063A is connected via a CPLD acting as a 16 bit parallel to SPI interface to the MCU, and there's also a WM8804 i2s/SPDIF interface attached for digital output.
It's mostly working well, I can decode and encode audio files, the 5 band EQ is enabled and works fine, and the ADMixer is setup to pass thru audio from LINE1 and also gives control of its level via the adMixerGain register.

I encountered a minor problem with configuring the ADMixer. I've found 2 different definitions of the various fields in that register.
From the VS1063 datasheet, it says that ADRATE_MASK = (3<<4) and ADMIXER_RATE48 = (2<<4).
But in vs10xx_uc.h (from the vs1063an recording example appnote) is says ADRATE_MASK = 0x0003 and ADMIXER_RATE48 = 0x0002.(All other bitfield definitions seem to be shifted >> 4 too)

I can only get the audio from the LINE1 input if I set adMixerConfig with the values given in the app note instead of the datasheet values.
A second problem is that the LINE1 input is muted after encoding is cancelled and I have to clear and set the ADMixer Enable bit in the PlayMode parametric register to enable it again.

Both of these issues are mentioned as fixed in the VS1063 patches documentation, which is leading me to suspect that I'm doing something wrong writing the patch to the VS1063A at startup and maybe its not running. But the fact that I can start encoding without setting SM_RESET, and can do further decoding or encoding without needing a software reset also makes me think otherwise. (I just write 0x0050 to SCI_AIADDR instead of a software reset)
Is there a way to determine if the patch was loaded and executed successfully or are the issues I've listed above enough proof that it isn't ?

One thing to note, I'm not able to read DREQ quickly enough to see if it goes low after an SCI Read/Write, so instead I'm following the recommendation in the datasheet of waiting for the maximum write time for WRAMADDR/WRAM (100 CLKI) before further SCI Reads/Writes.
User avatar
pasi
VLSI Staff
Posts: 2019
Joined: Thu 2010-07-15 16:04

Re: VS1063 ADMixer config and patch issue.

Post by pasi »

The ROM code of vs1063a has a bug that uses parametric_x.playMode bits 5 and 4 for samplerate and bits 7 and 6 for channel configuration. This is wrong, it should be using parametric_x.adMixerConfig. PcmMixer overrides ADMixer, so if you set rates 1 or 3, you disable ADMixer.

The vs1063a patches package performs a check (not in the "encpatches" version of the patches package) in the idle hook to detect that ADMixer has been enabled, and then initializes it again using parametric_x.adMixerConfig . The rate and channel config seem to be taken from bits 5:4 and 7:6 respectively.

AdMixer is not intended to be used in the encoding mode. The encoding mode already provides the monitoring of the input to be encoded at the analog output. If you just want to monitor the analog inputs, you can do that in the decoding mode -- even if you're not sending any bitstream to decode.

If you still set AdMixer during encoding, you must make sure the rate of admixer matches the ADC rate the encoding uses. (Also, AdMixer can't work if the encoding is not using the ADC at a multiple of 24kHz.) Determining the rate isn't easy, because software and hardware rate conversions are in the chain, and the ADC is not run at the encoding rate. You would practically need to read the DECIM bits first.

So, can you describe in broad strokes what do you want to accomplish with the AdMixer?

Yes, when encoding finishes, it disables the ADC (and some other things), and thus the input data for AdMixer gets frozen.

Edit: With mp3 encoding you could keep the encoding going indefinitely, just start saving (probably want to sync to a mp3 frame start) and end saving when you wish. This way you'll always get the monitoring from the analog outputs even while you're not actually saving.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
Dman
User
Posts: 3
Joined: Tue 2022-07-05 17:44

Re: VS1063 ADMixer config and patch issue.

Post by Dman »

Hi Pasi, thanks for the reply and the helpful info about the AD Mixer.

First off, please ignore my theory that it was down to the patch code not loading. After RTFM on the patches, I saw there are 3 new encoding modes, and I can encode with the new mode 6 and create a file that shows up as stereo with identical L/R channel waveforms, so I'm 99% sure there's no problem loading the patch.

Also my "issue" with incorrect bitdefs for the adMixerConfig is 100% my fault. I've been tasked with updating and fixing up the software for this project but the original author didn't believe in comments or constants. So when I saw things like 'WriteParametric(0x1e0e, 2)' and could only find a match for it in the encoding appnote it kinda thew me onto the wrong track because the original driver 'worked'. Now I know bit 1 is ignored, it makes sense that the AD Mixer is really getting set up for for 192Khz stereo.
So, can you describe in broad strokes what do you want to accomplish with the AdMixer?
The original hardware is an MP3 decoder for retro hardware, and uses the Line1 input to mix in the audio from the computer so the user doesn't need any external mixers or a second set of speakers etc.
This side of things is working well, it's only when I started adding the missing encoding functions to the driver that I ran into a few issues with the ADMixer.
Yes, when encoding finishes, it disables the ADC (and some other things), and thus the input data for AdMixer gets frozen.
Ah, I'd misunderstood the description in the patch documentation of the bug that disables the monitoring when SCI_VOL is 0 and thought that's what I was experiencing when ADC wasn't reenabled after encoding was finished.

I didn't know the ADC was always disabled after encoding. It's not a major problem, I now set adMixerGain to -31, reenable the mixer and then ramp up the gain to the users previous setting to make it sound less jarring on the ears.

Thanks again for you help.
Post Reply