I was just wondering, does anyone know how to send the crystal speed to the VS1002d? I’ve got my code working except for it is being decoded at half speed (David Bowie sounds like a demented remake by the Crash Test Dummies). I’m pretty sure it’s a crystal problem but I can’t get it to work out the kinks. It doesn’t seem to care what value I send to the crystal register, it’ll only go from half speed to much lower than half speed. Does anyone have any experience working with the crystal on this chip?
Note to the guys at SparkFun: Maybe in the future a 24.576 MHz crystal would be better? I might be an idiot and not understand all the reasons, but at least that way you don’t have to write to any crystal configuration registers.
I solved this problem, but it was a long time ago (see date below!) so I can’t exactly remember what I did, but I went back and looked at the code I wrote and found the initialization routines I wrote for the VS1002d. I solved this problem on my own and then posted the results on a different forum, which I’ve linked to below in case you want to download all of the code and see the other posts on the subject.
'*******************************************************************************
Sub Vs_write(byval Vs_address As Byte , Byval Data1 As Byte , Byval Data2 As Byte)
'Simple - it sends commands to the VS1002.
Xcs = 0
B = Vs_wr
Shiftout Vs_mosi , Vs_clock , B , 1
Shiftout Vs_mosi , Vs_clock , Vs_address , 1
Shiftout Vs_mosi , Vs_clock , Data1 , 1
Shiftout Vs_mosi , Vs_clock , Data2 , 1
Xcs = 1
End Sub
'*******************************************************************************
Sub Vs_init()
'Hardware reset
Xreset = 1
Waitms 10
Xreset = 0
Waitms 10
Xreset = 1
Waitus 250
'Wait for Dreq to rise again.
Do
Led = Dreq
Loop Until Dreq = 1
'Software Reset
Vs_write &H0 , &H0 , &H4
'Wait for Dreq to rise again
Do
Led = Dreq
Loop Until Dreq = 1
'Set The Vs1002 Chip To New Mode, set crystal speed, and send a sample bit rate (8000 Khz)
Vs_write &H0 , &HC , &H20
Waitus 5
Vs_write &H3 , &H98 , &H00
Waitus 5
Vs_write &H5 , &H1F , &H41
End Sub
'*******************************************************************************
P.S. After looking through the code and hashing up not-so-fond memories, I think you might want to double-check your sample bit-rate. Post your code and I might be able to tell you more (or, quite possibly, less…).
I’m a little confused by why you chose a sample rate of 8kHz. Is that just some random value that works for a more standard sample rate like 44.1kHz? Was the David Bowie song sampled at that rate?
At this point I can’t tell you why I set that as the sample rate. No, none of the songs I used were at that rate, they were the standard 44.1 KHz or whatever. But I remember that having something to do with why it wasn’t working.
Check the datasheet against this section of code right here:
'Set The Vs1002 Chip To New Mode, set crystal speed, and send a sample bit rate (8000 Khz)
Vs_write &H0 , &HC , &H20
Waitus 5
Vs_write &H3 , &H98 , &H00
Waitus 5
Vs_write &H5 , &H1F , &H41
The datasheet will probably reveal more. OK, I couldn’t stop myself and had to look at one … I looked at the datasheet for the vs1033 because I have it on hand, but the vs1002 datasheet should also have the same section on “Sample Rate Considerations”. It looks like the only reason I did it was because the datasheet told me to!
Changing the sample and clk regs changes the playback speed, and tone which is to be expected. The weird thing is that no matter what its still garbled sound not resembling the piece of music I’m trying to send. It might be how i’m sending the data, but I’ve been successful in sending the “sine test” which uses the same bus as MP3 data. I’ve also checked any big/little endian compatibilities.
Describe “garbled” for me. Does it just sound like it’s playing super-slow or is it just static? When I was testing “Under Pressure”, I could definitely hear the bass line but it played at about half speed or less (kinda like those old Walkmans that had variable speed playback on super-slow).
What do your initialization/communication routines look like?
We actually just got it to work. As it turns out the SDI bus was sampling bits on the wrong clock edge. By changing the the SM_DACT bit in the mode register playback runs smoother. Thanks for your help.