Guys,
I tried to test VS1003 with ATMEGA128 ..
I gave me "hello" on the speaker, but I can't repeat it...any ideas why ?
The code I have written :
void VsSineTest(){ unsigned char *p; unsigned int i; p = HelloMP3; /* Reset MP3 chip */ //Mp3PutInReset(); /* Pull xRESET low -> hardware reset */ VS1003B_XRESET_L(); _delay_ms(100); /* 100 ms delay */ /* Send dummy SPI byte to initialize SPI bus of Atmel microcontroller */ VS1003B_WriteByte(0xFF); //SPIPutCharWithoutWaiting(0xFF); /* Un-reset MP3 chip */ VS1003B_XCS_H(); //Mp3DeselectControl(); /* Pull xCS high */ //Mp3DeselectData(); /* Pull xDCS high */ VS1003B_XDCS_H(); //Mp3ReleaseFromReset(); /* Pull xRESET high */ VS1003B_XRESET_H(); _delay_ms(100); /* 100 ms delay */ /* VS10xx Application Notes, chapter 4.8 ---------------------------------*/ /* As an example, let's write value 0x0820 to register 00 byte by byte */ VS1003B_XCS_L(); //Mp3SelectControl(); /* Pull XCS low, now SPI writes go to SCI port */ VS1003B_WriteCMD(00,0x0820); VS1003B_WriteCMD(SCI_VOL,0x0000); //max volume //SPIPutChar(0x02); /* Send SPI Byte, then wait for byte to be sent. */ //SPIPutChar(0x00); /* 0x02 was WRITE command, 0x00 is register number */ //SPIPutChar(0x08); /* This byte goes to MSB */ //SPIPutChar(0x20); /* ..and this is LSB. (0x20=Allow Test Mode) */ VS1003B_Delay(); //SPIWait(); /* Wait until Atmel MCU signals SPI write complete */ VS1003B_XCS_H(); usart_pstr("WAITING FOR DREQ ! \n"); //Mp3DeselectControl(); /* Pull XCS high, now SPI writes don't go to SCI port. */ loop_until_bit_is_set(VS1003B_PIN,VS1003B_DREQ); usart_pstr("\n DREQ = 1 \n \n"); //while (!MP3_DREQ) /* Wait for DREQ = 1 */ //; /* Do nothing while waiting for DREQ = 1 */ /* Send a Sine Test Header to Data port */ VS1003B_XDCS_L(); while (p <= &HelloMP3[sizeof(HelloMP3)-1]) { VS1003B_WriteByte(pgm_read_byte(p++)); } //Mp3SelectData(); /* pull XDCS low, now SPI writes go to SDI port */ VS1003B_WriteByte(0x53); VS1003B_WriteByte(0xef); VS1003B_WriteByte(0x6e); VS1003B_WriteByte(0x44); VS1003B_WriteByte(0x00); VS1003B_WriteByte(0x00); VS1003B_WriteByte(0x00); VS1003B_WriteByte(0x00); //SPIPutChar(0x53); /* - This is a special VLSI Solution test header - */ //SPIPutChar(0xef); /* - that starts a sine sound. It's good for - */ //SPIPutChar(0x6e); /* - testing your code and the chip. */ //SPIPutChar(0x44); //SPIPutChar(0x00); //SPIPutChar(0x00); //SPIPutChar(0x00); //SPIPutChar(0x00); //SPIWait(); VS1003B_Delay(); //Mp3DeselectData(); VS1003B_XDCS_H(); _delay_ms(500); /* 500 ms delay */ /* Stop the sine test sound */ VS1003B_XDCS_L(); //Mp3SelectData(); //SPIPutChar(0x45); //SPIPutChar(0x78); //SPIPutChar(0x69); //SPIPutChar(0x74); //SPIPutChar(0x00); //SPIPutChar(0x00); //SPIPutChar(0x00); //SPIPutChar(0x00); VS1003B_WriteByte(0x45); VS1003B_WriteByte(0x78); VS1003B_WriteByte(0x69); VS1003B_WriteByte(0x74); VS1003B_WriteByte(0x00); VS1003B_WriteByte(0x00); VS1003B_WriteByte(0x00); VS1003B_WriteByte(0x00); //SPIWait(); VS1003B_Delay(); //Mp3DeselectData(); VS1003B_XDCS_H(); _delay_ms(500); /* 500 ms delay */ usart_pstr("Sine wave test 's stoped, change to SPI High! \n"); VS1003B_XDCS_L(); // Pull XDCS low /* for (i=0; i<2048; i++) { while (bit_is_clear(VS1003B_PIN,VS1003B_DREQ)); // wait here until DREQ is high again //SPIPutChar(0); VS1003B_WriteByte(0); } VS1003B_Delay(0xffff); // Wait until SPI transfer is completed VS1003B_XDCS_H(); // Pull XDCS high _delay_ms(500); */ VS1003B_SoftReset(); } void main() { unsigned char *p; DDRB = 0b00000111; PORT_INI(); PORT_DREQ(); VS1003B_SPI_Low(); usart_init(BAUD_PRESCALE); usart_pstr("\n TESTING VS1003 with sine wave! \n"); while (1) { usart_pstr("Testing sine wave begins! \n"); VsSineTest(); _delay_ms(15000); usart_pstr("Test complete! \n \n"); } }
Any clues guys ?
Thanks