Page 1 of 1

MP3 encoding data are missing

Posted: Sat 2018-08-04 4:48
by Y_Tanaka
We are developping a MP3(32KHz 128Kb/s monoral) recording module by using
VS1063a and cortex M3.
We have a fatal problem in encording sequence.
Several times, the reading one frame data (which shoud be the same size)
from SCI_HDAT0 does not match around 40~200 bytes during recording of
approximately one hour. The DSP is worked in x5 clock and SCI clock is
programmed to 3 or 6MHz.
The omission of data seems to have already occurred when read it from the
SCI_DATA0. As a matter of course, the latest Plug-In supported.
What kind of problem following sequence will be considered as possibility?


--- start Encode MP3( 32KHz 128Kbps monoral) sequence ---

SCIEnable(); // enable SCI device
-- SCI CLOCK to 1MHz --
Vs1063aWriteSci(SCI_CLOCKF, val);
Vs1063aWriteSci(SCI_AICTRL0, 32000UL); // 32KHz sampling
Vs1063aWriteSci(SCI_AICTRL1, 0x00);
-- SCI_CLOCKUP to 6MHz--
Vs1063aLoadUserCode(); // patches loading(2017/03/29 full)
Vs1063aWriteSci(SCI_WRAMADDR, CBR | x1000 | 128); // 128KBPS set
: :

wordsn = Vs1063aReadSci(SCI_HDAT1); // read encoded words number
if (wordn > 0)
{
for (i=0; i<wordsn; i++)
{
val = Vs1063aReadSci(SCI_HDAT0);
SetEncodeBuf(val >> 8); // set upper data to buffer
SetEncodeBuf(val & 0x00FF); // set lower data to buffer

Re: MP3 encoding data are missing

Posted: Mon 2018-08-06 9:12
by Panu
Hello!

I don't think that VS1063 guarantees that the is pushed to the buffer exactly one frame at a time. But I suppose that is not the problem?

Could it be that you simply don't read the data fast enough?

Can you give a specific example of what goes wrong, e.g. when you run this...

Code: Select all

wordsn = Vs1063aReadSci(SCI_HDAT1); // read encoded words number

if (wordn > 0) for (i=0; i<wordsn; i++) {
  val = Vs1063aReadSci(SCI_HDAT0);
  SetEncodeBuf(val >> 8); // set upper data to buffer
  SetEncodeBuf(val & 0x00FF); // set lower data to buffer
}
... can you give an example of what is the value of wordsn and what is the value of wordsn the next time you run it?

Also, how long does it take to execute the FOR loop? Can you measure it with an oscilloscope? And how long time is there between two runs of the first line (the one that reads the SCI_HDAT1 register) in the worst case?

-Panu

Re: MP3 encoding data are missing

Posted: Tue 2018-08-07 13:05
by pasi
Where are you saving or sending the encoded data?

If you are saving to SD card, then you may be experiencing large latency between some of the writes. Some cards behave better than some others in this respect.

If it suddenly takes 200-500ms to write a sector, then the FIFO in vs1063a will overflow and you will miss data.