Hi!
I recently bought a Music Shield from Seeed Studio (http://goo.gl/uMVOv) that has the VS1053b chip, a micro SD card, iPod connector and some buttons that are all controlled by SPI and Port Manipulation. (I think the shield is wired so you only can use Port Manipulation)
Anyhow. I'm completely new to microcontrollers and while I did use to to C and C++ development waaay back in time I never did any (to me) advanced stuff like using hexadecimals, bit shifting, etc. So this was like jumping in to the deep end of the pool. Specially since the code provided by them seems like a true cut n paste job.
So I decided to try to get the "Hello" example to work and thanks to code from this thread and code from Seeed I've managed to get it working on an Arduino UNO and an Arduino Mega 2560.
However I'm still at the deep end of the pool. I've read the VS1053b datasheet but most of it is still jibberish to me. So I'm wondering anyone has any tips for tutorials or books that can help me get my head around SPI, SCI Registers, Datasheets that doesn't assume that I already understand the math involved?
For example in the VS1053b datasheet page 40 (8.7.4 SCI_CLOCKF) the last line on that page says:
Example: If SCI_CLOCKF is 0x8BE8, SC_MULT = 4, SC_ADD = 1 and SC_FREQ = 0x3E8 = 1000.
How do I decode that with my minimal knowledge.
Or if looking at code:
Mp3WriteRegister(SPI_MODE, 0x08, 0x04);
Mp3WriteRegister(SPI_CLOCKF, 0x3b, 0xfe);
What does that actually break down to. And how can I figure that out using a calculator.
So yea. That's the type of book or tutorial I'm looking for.
Cheers
.r
Audible "Hello" example for VS1003B + Microcontroller
Re: Audible "Hello" example for VS1003B + Microcontroller
Hi! I can try to help a litte. It's not very easy to explain... you need to do some hexadecimal arithmetic and bit shifting as you said.Example: If SCI_CLOCKF is 0x8BE8, SC_MULT = 4, SC_ADD = 1 and SC_FREQ = 0x3E8 = 1000.
How do I decode that with my minimal knowledge.
First of all you need to know what the bit positions in the register are, from the same datasheet page:
Code: Select all
SCI_CLOCKF bits
Name Bits Description
SC_MULT 15:13 Clock multiplier
SC_ADD 12:11 Allowed multiplier addition
SC_FREQ 10: 0 Clock frequency
Let's breakdown the example "SC_MULT = 4, SC_ADD = 1 and SC_FREQ = 0x3E8 = 1000" using the Windows Calculator:
- Start calculator (calc.exe), set "Scientific" mode (View->Scientific). Use decimal mode (Dec).
Set 4 to SC_MULT:
- From the table see that SC_MULT is bits 15 to 13. It means we need to shift the SC_MULT value left by 13 bits.
- Enter "4", "Lsh", "13", "=". The value is 32768. Write this down. (you can click "Hex" to see it in hex: 8000)
Set 1 to SC_ADD:
- From the table see that SC_ADD ends at bit 11. So we need to left shift the SC_ADD value by 11 bits.
- Click "C" and "Dec" to reset the calculator into decimal mode.
- Enter "1", "Lsh" , "11", "=". The value is 2048. Write this down.
Set 1000 to SC_FREQ:
- From the table we see that SC_FREQ ends at bit 0 (it's in bits 10:0 which means "bits 10 downto 0"), so we don't need to shift it. So just write down "1000".
Then add together all that we have written down, "32768" + "2048" + "1000". We get 35816. Then click "Hex" to see it in hex: 8BE8.
This would be written into the SPI_CLOCKF register in 2 bytes, split at the middle:
Mp3WriteRegister(SPI_CLOCKF, 0x8B, 0xE8);
Hope this helps, at least a little...
-Panu
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo
Panu-Kristian Poiksalo
-
- User
- Posts: 4
- Joined: Wed 2011-11-16 12:29
Re: Audible "Hello" example for VS1003B + Microcontroller
Hi,
I am attaching my code for audible "Hello"...I did interfacing of VS1033D with ARM7(MCB2140 Board)..Thanks to this forum for giving me great guidance...and Best wishes to the team of VLSI solution development ..
I am attaching my code for audible "Hello"...I did interfacing of VS1033D with ARM7(MCB2140 Board)..Thanks to this forum for giving me great guidance...and Best wishes to the team of VLSI solution development ..

- Attachments
-
- Audible Hello.zip
- (6.32 KiB) Downloaded 1219 times
Re: Audible "Hello" example for VS1003B + Microcontroller
Thank you!
-Panu
-Panu
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo
Panu-Kristian Poiksalo
Re: Audible "Hello" example for VS1003B + Microcontroller
Thank you so much, Panu, for working on it!
Re: Audible "Hello" example for VS1003B + Microcontroller
Hi, First,Tks for the example! When use the"Hello" example for VS1003B+MCU, I meet a problem-
VS1003 can play "hello"repeatly. So I try a WMA file, it can also play repeatly. But when I play a MID file , it only play once correctly,and then output the noise. After Reset the MCU, it also play once correctly.Why not play a MID file repeatly? pls guide me ,TKS!
VS1003 can play "hello"repeatly. So I try a WMA file, it can also play repeatly. But when I play a MID file , it only play once correctly,and then output the noise. After Reset the MCU, it also play once correctly.Why not play a MID file repeatly? pls guide me ,TKS!
Re: Audible "Hello" example for VS1003B + Microcontroller
Hi!
Maybe the problem is that because MIDI file has so small bitrate, the stream buffer of VS1003 can contain MIDI data for a long time after the file is played. Maybe you need to do a software reset (bit 4 of SCI_MODE) after the MIDI song.
I think there was a similar posting about this kind of problem about 1 year ago in the forum... maybe you can see if you can find it?
-Panu
Maybe the problem is that because MIDI file has so small bitrate, the stream buffer of VS1003 can contain MIDI data for a long time after the file is played. Maybe you need to do a software reset (bit 4 of SCI_MODE) after the MIDI song.
I think there was a similar posting about this kind of problem about 1 year ago in the forum... maybe you can see if you can find it?
-Panu
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo
Panu-Kristian Poiksalo
Re: Audible "Hello" example for VS1003B + Microcontroller
I just wanted to thank everyone here who has contributed code for these great decoder series.
Without you I would have been stumped forever and given up.
I program in Bascom AVR and have little time to learn C. Most of my projects are simple and Basic covers everything I need.
once again
BIG THANK YOU to ALL
Patrick.
Without you I would have been stumped forever and given up.
I program in Bascom AVR and have little time to learn C. Most of my projects are simple and Basic covers everything I need.
once again
BIG THANK YOU to ALL
Patrick.
Re: Audible "Hello" example for VS1003B + Microcontroller
This thread is very helpful for beginner such as me. I am working with VS1003B, and Stellaris Lm3s3748 of TI. I have passed SPI and sine test, but when I try to play a music, it is not working. I have found that DREQ of VS1003B is always 1 (3.3V) so my micro Controller send continuously and there no music played.
I wan to ask that what is the regular reason of this error?
Thanks a lot.
I wan to ask that what is the regular reason of this error?
Thanks a lot.
Re: Audible "Hello" example for VS1003B + Microcontroller
Check that the microcontroller pin that DREQ is connected to is set to input mode.letanphuc wrote:I have found that DREQ of VS1003B is always 1 (3.3V) so my micro Controller send continuously and there no music played.
Other possibilities are chip select handling (only change xCS and xDCS when SPI is idle), wrong spi clock polarity, you send wrong data, or the file has unsupported audio format.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook