Simple VS1010 application

Designing hardware and software for systems that use the VS1010 MP3 Audio DSP Microcontroller.
Daniel.mp3
User
Posts: 6
Joined: Mon 2020-12-14 13:21

Simple VS1010 application

Post by Daniel.mp3 » Mon 2020-12-14 13:38

Hi! I'm a student from germany and this is my first own project. So I'm not a pro at all..
So now to my task:
-a µC controlls the VS1010.
-the device can be controlled by a commandline(UART)
-the volume can be controlled
-files can be selected by integer values
- different directorys can be selected by integer values
- it can be selected if the file plays 1 time, n times, or in loop
- sequences of files can be configured an played

So I saw in the VS1010 handbook that a Default Player is stored in the ROM. Is it the best way to use this default player? What is the best way to start the project? I have the developer board and coded a little bit, but I don#t know how to get it going.

Thanks for the help!

Best wishes and stay healthy!

Hannu
Senior User
Posts: 145
Joined: Mon 2016-05-30 11:54

Re: Simple VS1010 application

Post by Hannu » Mon 2020-12-14 14:41

Hello and welcome to the forum!

First start with this: viewtopic.php?f=15&t=2128 and get familiar with the developer board.
The rom default player is rather limited. So you need some software for VS1010.

I would write the UART handler first. This program should just print stuff out so that you know your parser works and you can test with terminal and UART cable. After that I would add more features piece by piece and testing. When most needed pieces work like they should, I would start controlling the audio decoder.

Code: Select all

void justSampleIdidntTestThisAtAllSomeAdditionalProgrammingNeeded() {
char c = 0;
static char myBuf[25];
while(c != 3) { /* CTRL-C */
  if (ioctl(stdin, IOCTL_CHECK_INPUT_AVAILABLE, NULL) > 0) { /* There is data */
    c = fgetc(stdin);
    if (c == 'D') { /* directory */
      u_int16 dirnum;
      fgets(myBuf, 24, stdin);
      dirnum = atoi(myBuf); /* and then select the dir */
    else if (c == ??) {

    }
  }
}
}
As you have the the book, you can study how to write the player callbacks, handle directories and so on.
Also take a look at rom code (same link above) when something feels funny, it is good place to check how it really is done. Also magic keyboard shortcut is CTRL-Shift-F and library find which searches through header files.

Also try to go through this forum for some code examples. One project which you might be interested is treeplayer: viewtopic.php?f=15&t=2430

Hope this helps and ask more when you find something which isn't obvious.

Daniel.mp3
User
Posts: 6
Joined: Mon 2020-12-14 13:21

Re: Simple VS1010 application

Post by Daniel.mp3 » Mon 2020-12-14 16:13

So I tested the Code in the book but it didn't work as planed.

#include <vo_stdio.h>
#include <volink.h> // Linker directives like DLLENTRY
#include <apploader.h> // RunLibraryFunction etc
#include <vs1010bRom.h>
#include <vo_gpio.h>
#include <vs1010b.h>
#include <playerinfo.h>
#include <string.h>
#include <protocol.h>
#include <spitv.h>
#include <lcd.h>
#include <devboard.h>

void MyPlayerCallback(AUDIO_DECODER *auDec, u_int16 samples){
printf(".");
}

ioresult main (char *params) {
GpioSetAsInput(BUTTON_B0);
GpioSetAsInput(BUTTON_B1);
GpioSetAsInput(BUTTON_B2);
GpioSetAsInput(BUTTON_B3);
DelayL(100000);

SetJmpiHookFunction(PlayerCallback, MyPlayerCallback);

printf("Press button B3...B3 to play, ESC or PWR button ends.\n");
while(1){
if(lastReceivedCharUart0==24)break;//ESC
if(PERIP(ANA_CF1)&ANA_CF1_PWRBTN)break;//PWR button
if(!GpioReadPin(BUTTON_B0))shellcmd("play","R:hello.mp3");
}

SetJmpiHookFunction(PlayerCallback, DefaultPlayerCallback);

return S_OK;
}

These are the errors:

C:\Users\DanRie\Documents\solutions\MySolution\main.c (28) ERROR 9: undefined identifier 'SetJmpiHookFunction'
C:\Users\DanRie\Documents\solutions\MySolution\main.c (28) ERROR 130: function call without a prototype
C:\Users\DanRie\Documents\solutions\MySolution\main.c (34) ERROR 9: undefined identifier 'shellcmd'
C:\Users\DanRie\Documents\solutions\MySolution\main.c (34) ERROR 130: function call without a prototype
C:\Users\DanRie\Documents\solutions\MySolution\main.c (37) ERROR 9: undefined identifier 'SetJmpiHookFunction'
C:\Users\DanRie\Documents\solutions\MySolution\main.c (37) ERROR 130: function call without a prototype

Hannu
Senior User
Posts: 145
Joined: Mon 2016-05-30 11:54

Re: Simple VS1010 application

Post by Hannu » Tue 2020-12-15 8:41

Daniel.mp3 wrote:
Mon 2020-12-14 16:13
So I tested the Code in the book but it didn't work as planed.

#include <vs1010bRom.h>
b? is your chip really VS1010B? I have strong belief that you are using VS1010D.
In the boot messages you should see line: VS1010D VSOS 4.20
#include <vs1010b.h>
#include <vs1010c.h>
These are the errors:

C:\Users\DanRie\Documents\solutions\MySolution\main.c (28) ERROR 9: undefined identifier 'SetJmpiHookFunction'
C:\Users\DanRie\Documents\solutions\MySolution\main.c (28) ERROR 130: function call without a prototype
C:\Users\DanRie\Documents\solutions\MySolution\main.c (34) ERROR 9: undefined identifier 'shellcmd'
C:\Users\DanRie\Documents\solutions\MySolution\main.c (34) ERROR 130: function call without a prototype
C:\Users\DanRie\Documents\solutions\MySolution\main.c (37) ERROR 9: undefined identifier 'SetJmpiHookFunction'
C:\Users\DanRie\Documents\solutions\MySolution\main.c (37) ERROR 130: function call without a prototype
Compiler errors, which are much easier than linker errors. Compiler can't find SetJmpiHookFunction (vs1010c.h, but are really in lowlevels.h) or shellcmd (vs1010dRom.h) declrations and those binaries are in VS1010D rom.

Are you sure, you started with vs1010D template, as shown in the attachment?
Because wrong template causes linkage against wrong ROM.
Attachments
new1010dproject.png
Screenshot of creating new VS1010D project
new1010dproject.png (8.5 KiB) Viewed 809 times

Daniel.mp3
User
Posts: 6
Joined: Mon 2020-12-14 13:21

Re: Simple VS1010 application

Post by Daniel.mp3 » Wed 2020-12-16 13:44

Thanks!
That was the problem. I had the old VSIDE software, so I had not the option to choose VS1010D.

I have now a similar problem

Code: Select all

#include <vo_stdio.h>
#include <volink.h>     // Linker directives like DLLENTRY
#include <apploader.h>  // RunLibraryFunction etc
#include <vs1010dRom.h>
#include <vo_gpio.h>
#include <vs1010c.h>
#include <playerinfo.h>
#include <string.h>
#include <protocol.h>
#include <spitv.h>
#include <lcd.h>
#include <devboard.h>

u_int16 track=1;
u_int16 nextTrack=0;
u_int16 keepPlaying=1;
u_int16 b0debounce=0;
u_int16 b1debounce=0;

void MyPlayerCallback(AUDIO_DECODER *auDec, u_int16 samples){
	if(AudioBufFill()>1500){
		if(lastReceivedCharUart0==27)keepPlaying=0;
		if(PERIP(ANA_CF1)&ANA_CF1_PWRBTN)keepPlaying=0;

		if(b0debounce && !GpioReadPin(BUTTON_B0))return;
		b0debounce=0;
		if(b1debounce && !GpioReadPin(BUTTON_B1))return;
		b0debounce=0;
		
		if(!GpioReadPin(BUTTON_B0)){
			b0debounce=1;
			nextTrack=track+1;
			player.auDec.cs.cancel=1;
		}
		
		if(!GpioReadPin(BUTTON_B1)){
			b1debounce=1;
			nextTrack=track-1;
			player.auDec.cs.cancel=1;
		}
	}
	if(!keepPlaying)player.auDec.cs.cancel=1;
}

ioresult main (char *params) {
	GpioSetAsInput(BUTTON_B0);
	GpioSetAsInput(BUTTON_B1);
	GpioSetAsInput(BUTTON_B2);
	GpioSetAsInput(BUTTON_B3);
	DelayL(100000);
	SetJmpiHookFunction(PlayerCallback, DefaultPlayerCallback);	
	
	strcpy(player.fileSpec, "D:music/*.mp3");
	player.currentFile=1;
	player.nextStep=1;
	while(keepPlaying){
		player.currentFile=track;
		if(PlayerPlayFile()==E_FILE_NOT_FOUND)track=0;
		if(nextTrack){
			track=nextTrack;
			nextTrack=0;
		}else{
			track++;
		}
	}
	
	SetJmpiHookFunction(PlayerCallback, DefaultPlayerCallback);
	return S_OK;
}
And this are the errors

Code: Select all

C:\Users\DanRie\Documents\solutions\Players\main.c (24) ERROR 9: undefined identifier 'AudioBufFill'
C:\Users\DanRie\Documents\solutions\Players\main.c (24) ERROR 130: function call without a prototype
I thaugtht that AudioBufFill is already a function in the RAM

Daniel.mp3
User
Posts: 6
Joined: Mon 2020-12-14 13:21

Re: Simple VS1010 application

Post by Daniel.mp3 » Wed 2020-12-16 13:46

A other problem is that "D:music/*.mp3".
"/*" after this is all a comment. How can I fix this problem?

User avatar
pasi
VLSI Staff
Posts: 1764
Joined: Thu 2010-07-15 16:04

Re: Simple VS1010 application

Post by pasi » Wed 2020-12-16 15:33

In C you can escape (almost) any character in a string with a backslash (except those that produce special characters, e.g. \n is a newline and \r is carriage return). So, something like "D:music\/\*.mp3" should work, so that the preprocessor doesn't see a comment mark.

But, the preprocessor I'm using seems to know not to look for comment start combinations inside quotes anyway, so I'm not sure that your issue is with the string.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

Hannu
Senior User
Posts: 145
Joined: Mon 2016-05-30 11:54

Re: Simple VS1010 application

Post by Hannu » Wed 2020-12-16 16:09

AudioBufFill() is defined in audio.h header.

A good trick is to highlight the unknown function in vside and with right click find it or ctrl-shif-f and use library find.

Daniel.mp3
User
Posts: 6
Joined: Mon 2020-12-14 13:21

Re: Simple VS1010 application

Post by Daniel.mp3 » Tue 2021-01-26 15:32

Hi, me again.

I'm searching for a compatible 12.288MHz parallel-resonant crystal. I found the attached one. Do you think this one is good or can you recommend one? I didn't find a BOM of the developer board.

Best wishes
Daniel
Attachments
2864166.pdf
(224.51 KiB) Downloaded 10 times

Daniel.mp3
User
Posts: 6
Joined: Mon 2020-12-14 13:21

Re: Simple VS1010 application

Post by Daniel.mp3 » Wed 2021-01-27 18:44

Hi,
a really important question: Do I need a Flash Memory? I definetly need a little bit of code. While development I will store the code in the sd card. But later, when the project is done, the program should not be in the sd card. Is it necessary to have a external memory or is the memory in the VS1010 big enough?

I'm really sorry for not having the most intelligent questions. I'm just a student who has much to learn.

Best wishes!

Post Reply