Although it is not on the datasheet, I think it would be necessary to set the mode register.
The music shield does a Software Reset with the following values...
Mp3WriteRegister (SPI_MODE, 0x08, 0x04); /* Newmode, Reset, No L1-2 */
delay(1);
while (!MP3_DREQ) /* wait for startup */
0x0804 is 0000 1000 0000 0100 (ie the first 0 is written to register bit 15)
SDI-NEWMODE(11) - ON
Soft Reset(2)
It also writes the clock doubler and misc audio data. I dont think this is necessary though as its not mentioned in the data sheet at all. This makes me think that resetting clears the all the registers except the mode register (reset bit is auto cleared). I need to check that Mode(bit 11) stays set ensure SDI NEW mode is entered. Unreliability of serial prints makes it difficult to check. Probably wouldn't hurt to send 0000 1000 0000 0000 0x0800 to be sure.
/* Set clock register, doubler etc. */
Mp3WriteRegisterWithDelay(SPI_CLOCKF, 0xB8, 0x00);
while (!MP3_DREQ);
Mp3WriteRegister(SPI_AUDATA, 0xAC,0x45);
while (!MP3_DREQ);
Steps From the DataSheet
- Set the VS1053b clock to the highest value just below 55.3 by writing 0xC000 to register SCI_CLOCKF (3)
Write1053Sci(SCIR_CLOCKF, 0xC0, 0x00);
- Set SCI_BASS (2) to 0.
- Reset VS1053b by setting bit SM_RESET (2) to 1 in register SCI_MODE (0). At the same time, clear bit SM_ADPCM (12) to 0. Remember that resetting takes time, so don’t do any firther register writes before the DREQ pin has risen.This step seems unneccessary as reseting at this point would remove the previous two steps. In the music shield example (Alsso OGG) this step is removed and is also not mention in the PCM recording instructions.
Write1053Sci(SCIR_MODE, 0x08, 0x04); // 0000 1000 0000 0000 0100
while(!digitalRead(MP3_DREQ)) ;
- Disable all interrupts except the SCI interrupts.In the music shield example the AIADDR register is also cleared. This is also mentioned in the PCM recording datasheet.
Mp3WriteRegister(SPI_AIADDR, 0x00,0x00);).
Mp3WriteRegister(SPI_WRAMADDR, 0xC0,0x1A);
Mp3WriteRegister(SPI_WRAM, 0x00,0x02); - Load the plugin profile you intend to run (Chapter 4). Note that you will have to redo this each time you want to activate recording.This poses a problem as you cant store a file on the Arduino. For the moment I will be using the .plg low quality voice profile. To save hassle I think i will try copying the vector variable to my sketch and reading it that way, avoiding the need for an SD card. The Ogg vorbis encoder will not fit on the arduino uno however the PCM profile is much smaller.
- Write1053Sci(SCIR_MODE, 0x18, 0x00); //0001 1000 0000 0000 for new mode For Line:Set bit SM_ADPCM (12) in register SCI_MODE (0) to 1.For Mic input
Write1053Sci(SCIR_MODE, 0x58, 0x00); //0101 1000 0000 0000 for new mode
- Set recording level control registers SCI_AICTRL1 (13) and SCI_AICTRL2 (14). Typical good values for conservative AGC are 0 and 4096, respectively.
/* If 0, use AGC */
Write1053Sci(SCIR_AICTRL1, 0x00, 0x00);
/* set to 4096 */
Write1053Sci(SCIR_AICTRL2, 0x10,0x00); // 0001 0000 0000 0000 = 4096 (decimal)
- If you want to use a VU meter, write 0x8000 to SCI_AICTRL0 (12) if using a mono profile or 0x8080 is using a stereo profile.No Need:Write1053Sci(SCIR_AICTRL0, 0x00, 0x00);
- Set a proper value ( 0) to SCI_AICTRL3 (15).Write1053Sci(SCIR_AICTRL3, 0x00, 0x00)
- If you use a profile that support Vox, set Vox registers. For details, see Chapter 2.5.
Not gonna look into this yet
- Activate the encoder by writing 0x34 to register SCI_AIADDR (10).
Mp3WriteRegister(SPI_AIADDR, 0x00,0x34); - Wait until DREQ pin is high before reading any data.
No comments:
Post a Comment