The main aim was create library to initialize codec vs1053 with atmega microcontroller to simple sound test - say 'hello'.
Detailed information are described in Datasheet VS1053, Application Notes VS10XX.
C library is determined for controlling Ogg Vorbis/MP3/AAC/WMA/FLAC/MIDI AUDIO CODEC using 7 pin SPI Bus. It contains only primitive functions for testing purposes.
Connection for VS1053 MP3 Shield for Arduino Uno R3.
PIN VS10XX | PIN ATMEGA328P | Description |
---|---|---|
5V | 5V | Supply Voltage |
AGND | GND | Ground |
SCLK | PB5 | Clock for serial bus |
MISO | PB4 | Master IN slave OUT |
MOSI | PB3 | Master OUT slave IN |
XCS | PB6 | Chip select input |
DREQ | PD2 | Data request, input bus |
XDCS | PD7 | Data chip select |
XRES | PB0 | Reset |
Prior defined for MCU Atmega328p, Atmega8.
Library was tested and proved on a VS1053 MP3 Shield with Arduino UNO R3. The Arduino was without a bootloader installed, it was only raw Atmega328P microcontroller. This hardware configuration was chosen for simplicity
Init sequence (according to source code documentation):
// +---------------------------------------------+
// | INIT VS10XX MP3 DECODER |
// +---------------------------------------------+
// |
// +---------------------------------------------+
// | PORTs / PINs SETTINGS |
// |---------------------------------------------|
// | OUTPUTs:VS10XX_MOSI, VS10XX_SCK, VS10XX_XCS |
// | VS10XX_XDCS, VS10XX_XRES |
// | INPUTs:VS10XX_MISO, VS10XX_DREQ (pullup) |
// +---------------------------------------------+
// |
// +---------------------------------------------+
// | SPI SLOW SPEED INIT / F = 125 kHz |
// |---------------------------------------------|
// | SPCR <= SET (SPE, MSTR, SPR1, SPR0) |
// +---------------------------------------------+
// |
// +---------------------------------------------+
// | RESET |
// -----------------------------------------------
// | activate RESET (low level) |
// | wait 22000 clk cycle (1.8 ms) |
// | send SPI dummy byte |
// | deactivate XCS, XDCS (high level) |
// | deactivate RESET (high level) |
// | activate analog powerdown mode (VOL=0xffff) |
// | set clock, mul, add => (CLOCKF=0x8800) |
// | wait for DREQ high |
// | slow sample rate 10 Hz (AUDATA=0x000A) |
// | wait 100ms |
// | turn on analog parts (VOL=0xfefe) |
// | 8kHz mono (AUDATA=0x1F41) |
// | set volume, for exmaple (VOL=0x6666) |
// +---------------------------------------------+
// |
// +---------------------------------------------+
// | SOFT RESET |
// -----------------------------------------------
// | native SPI modes,soft reset (MODE=0x0804) |
// | wait 1ms |
// | wait for DREQ high |
// | set clock, mul, add => (CLOCKF=0x8800) |
// | wait 1ms |
// | wait for DREQ high |
// | activate data (XDCS low level) |
// | send data four times 0x00 |
// | deactivate data (XDCS high level) |
// +---------------------------------------------+
// |
// +---------------------------------------------+
// | SPI FAST SPEED INIT / F = 1 MHz |
// -----------------------------------------------
// | SPSR <= SET (SPI2X) |
// | SPCR <= SET (SPE, MSTR, SPR0) |
// +---------------------------------------------+
- VS1053_TestSci (void) - sound test of sending command
- VS1053_TestSine (uint8_t) - sound test of sine wave with specific frequency, defined 1kHz or 5kHz
- VS1053_TestMemory (void) - memory test of particular sections ROM, RAM
- VS1053_TestSample (const char*, uint16_t) - sound test of saying 'hello'