|
|
View previous topic :: View next topic |
Author |
Message |
mdb486
Joined: 09 Feb 2009 Posts: 2
|
PIC18F and VS1011 |
Posted: Fri Mar 06, 2009 8:21 pm |
|
|
Hey, Does anyone have an experience working with the VS1011 mp3 decoder chip?
I have been looking at several projects that use this chip, mainly this one: http://www.walrus.com/~raphael/mp3/MMC_version/sakura_24.576mhz_version.c
I tried to re-write this code to use the hardware SPI, by usuing SETUP_SPI. I also wrote a function to do a sine sweep, to make sure that the chip is working properly. As of right now, I am just getting static noise out of the VS1011.
This is the first project that I have tried to use the hardware SPI, I have a feeling that the way I am using the SPI is incorrect.
Here is my code, if anyone could help me out I would appreciate it.
I am using a PIC 18F452
Code: |
#fuses HS,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#byte READ = 0x03
#byte WRITE = 0x02
char volume = 0;
void vs_sci(char inout, addr, data1, data2);
void vs_reset_hard(void);
void vs_reset_soft(void);
void vs_sine_test(void);
void main()
{
setup_spi(SPI_MASTER | SPI_H_TO_L | SPI_CLK_DIV_4 | SPI_SS_DISABLED);
vs_reset_hard();
vs_reset_soft();
vs_sine_test();
while(1);
}
void vs_reset_hard(void)
{
output_high(XCS);
output_high(XDCS);
delay_ms(500);
do{
output_low(XRESET);
delay_cycles(100);
output_high(XRESET);
delay_cycles(500);
vs_sci(0x02,0x00,0x00,0x04);
delay_ms(100);
}while(!DREQ);
delay_ms(1);
vs_sci(0x02,0x00,0x08,0x00);
delay_ms(1);
vs_sci(0x02,0x0b,volume,volume);
delay_ms(1);
}
void vs_reset_soft(void)
{
vs_sci(0x02,0x00,0x08,0x04);
delay_ms(1);
vs_sci(0x02,0x0b,volume,volume);
delay_ms(1);
}
void vs_sci(char inout, addr, data1, data2)
{
output_high(XDCS);
output_low(XCS);
SPI_WRITE(inout);
SPI_WRITE(addr);
SPI_WRITE(data1);
SPI_WRITE(data2);
output_high(XCS);
}
void vs_sine_test(void)
{
printf("SINE TEST\n\r");
vs_sci(0x02, 0x00, 0x08, 0x20);
while(!DREQ);
output_low(XDCS);
SPI_WRITE(0x53); // Sine Command
SPI_WRITE(0xEF);
SPI_WRITE(0x6E);
SPI_WRITE(0x44); // Frequency
SPI_WRITE(0x00);
SPI_WRITE(0x00);
SPI_WRITE(0x00);
SPI_WRITE(0x00);
delay_ms(500);
SPI_WRITE(0x45); // End Sine Command
SPI_WRITE(0x78);
SPI_WRITE(0x69);
SPI_WRITE(0x74);
SPI_WRITE(0x00);
SPI_WRITE(0x00);
SPI_WRITE(0x00);
SPI_WRITE(0x00);
delay_ms(500);
output_high(XDCS);
printf("END SINE TEST\n\r");
}
|
Thanks |
|
|
Sydney
Joined: 13 Feb 2009 Posts: 71
|
|
Posted: Sat Mar 07, 2009 3:36 pm |
|
|
I think you may need to do:
Code: | setup_spi(SPI_MASTER | SPI_H_TO_L | SPI_XMIT_L_TO_H | SPI_CLK_DIV_4 | SPI_SS_DISABLED); |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Mar 07, 2009 5:34 pm |
|
|
Don't use this parameter on an SPI Master. It's only intended for use
when the setup_spi() statement is defining an SPI slave.
Quote: | #byte READ = 0x03
#byte WRITE = 0x02 |
This is wrong. The #byte directive is normally used to tell the compiler
the address of a hardware register in the PIC. I believe you want to
define commands for your chip. You should do it this way:
Code: |
#define READ 0x03
#define WRITE 0x02 |
|
|
|
mdb486
Joined: 09 Feb 2009 Posts: 2
|
|
Posted: Mon Mar 09, 2009 2:17 pm |
|
|
Thanks for the replies!
I will give those a shot. I might have a problem with my hardware as well, but I ordered a breakout board from sparkfun for the vs1011, so I will give a shot on that board when I get it in. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|