Timer

completely seperate from the breadboard power supply, and if you look at the pictures, and see the red and green wire going to the breadboard, between them i get 0 resistance, doesnt sound right?

I have managed to remove the short there, i dont know how but fiddled with things, then retested and no short. I repgrogramed the chip with this code:

#include <avr/io.h>
int main( void )
        {
DDRD |= (1<< PD2);
DDRB |= (1<< PB1);
while(1)
{
		while(PIND&(1<<PD2))
		{
		}

		PORTB |= (1<< PB1);
}
   return 1;

        }

I dont know what happens on PD2 because whether the button is pressed or not the led comes on, but at least the led is coming on!!

So why then when i run this program do no leds come on???

/*******************************************************************/
/*          Mega8 MP3 Player (mega8 + VS1003 + SD)  V1.8           */
/*                                                                 */
/* Discription: Can play mp3/wma/wav/mid SF0 files in the root     */
/*              directery on the SD card which file system is FAT16*/
/*              or FAT32.                                          */
/*              It has six keys to control this player             */
/*              MODE: switch between repeat all (default),repeat 1 */
/*                    and shuffle                                  */
/*              PLAY/PAUSE:                                        */
/*              PREV: previous songs                               */
/*              NEXT: next songs                                   */
/*              UP  : volume up                                    */
/*              DOWN: volume down                                  */
/* Platform   : AVRStudio4.13 b528 + WinAVR20070525                */
/*              optimize -0s                                       */
/* Author     : bozai(Zhang Qibo)                                  */
/* E-mail     : sudazqb@163.com                                    */
/* MSN        : zhangqibo_1985@hotmail.com                         */
/* Date       : 2007-06-16                                         */
/*******************************************************************/
/*  V1.8                                                           */
/*  2007-06-16                                                     */
/*  Still the bug of FAT, it's not resolved totally                */
/*                                                                 */
/*  V1.7                                                           */
/*  2007-05-21                                                     */
/*  Fix a serious bug of FAT                                       */
/*  Set the default mode to "Shuffle"                              */
/*  Because the mode button is inside the box                      */
/*  So I don't want to open the box when I turn on it              */
/*  If the button is easy to press of your mp3 player              */
/*  just change the macro below to:                                */
/*            0 = repet all    1 = repet one  2 = shuffle          */

#define DEFAULT_MODE   0

/*                                                                 */
/*  V1.6                                                           */
/*  2007-05-09                                                     */
/*  And a track function to make the shuffle a real shuffle        */
/*  Due to the limted RAM space of mega8. Maximum no repetition    */
/*  songs is 1024. And songs more than that will use randomly play */
/*  Special thanks to Ronald Ausloos (Belgium)'s advice            */ 
/*                                                                 */
/*  V1.5                                                           */
/*  2007-05-03                                                     */
/*  Change the behavior of the LEDs:                               */
/*                      VS1003 faild: LED1 blink                   */
/*                      SD faild    : LED2 blink                   */
/*                      FAT faild   : LED1 & LED2 blink alternatly */
/*                      File not found: Both LED blink             */
/*  Add read capacity function, fix the bug of FAT init            */
/*  Add slow start up code of VS1003                               */ 
/*                                                                 */                                                              
/*  V1.4                                                           */
/*  2007-05-02                                                     */
/*  Add enough delay when operate VS1003                           */ 
/*                                                                 */                                                              
/*  V1.3                                                           */
/*  2007-04-21                                                     */
/*  Modify the retry time of sd reset                              */
/*  Enable some code incase that when FAT initialize               */
/*  faild program can't jump out the loop                          */
/*  so the error LED can't light up                                */
/*  And light up both leds when FAT_Ini fails                      */
/*                                                                 */
/*  V1.2:                                                          */
/*  2007-04-04:                                                    */
/*  Add a macro of path                                            */
/*                                                                 */
/*  V1.1:                                                          */
/*  2007-02-25                                                     */
/*  Change the directory to C:\music\                              */
/*  A bug fixed                                                    */
/*  Modify some code to adjust new GCC compiler                    */
/*                                                                 */
/*  V1.0:                                                          */
/*  2006-12-03:                                                    */
/*  Original Version                                               */
/*******************************************************************/

#include<avr/io.h>
#include"MMC_SD/MMC_SD.h" //head files
#include"FAT/FAT.h"
#include"VS1003B/VS1003B.h"
#include<avr/pgmspace.h>

#define uint8 unsigned char
#define uint16 unsigned int
#define uint32 unsigned long


#define PATH (unsigned char *)("\\music")
//It's the path where the file placed
//Change it if you want to placed it to anoter foler
//The path should not have blanks, and each foler name's length should less than 8 with no extention

//diagnose and state indicate leds
//at start up this two led indicate error
//at normal they indicate the state of the MODE 
#define LED1_CON() DDRC|=_BV(PC5)
#define LED1_ON()  PORTC|=_BV(PC5)
#define LED1_OFF() PORTC&=~_BV(PC5)

#define LED2_CON() DDRB|=_BV(PB1)
#define LED2_ON()  PORTB|=_BV(PB1)
#define LED2_OFF() PORTB&=~_BV(PB1)

//keys
#define STOP _BV(PD2)
#define MODE _BV(PD3)
#define NEXT _BV(PD7)
#define UP   _BV(PD4)
#define DOWN _BV(PD6)
#define PREV _BV(PD5)

#define MP3 1
#define WMA 2
#define MID 3

//mode
#define REPET_ALL 0
#define REPET_ONE 1
#define RANDOM    2

extern uint16 SectorsPerClust;//ÿ´ØÉÈÇøÊý
extern uint16 FirstDataSector;//µÚÒ»¸öÊý¾ÝÉÈÇøÊý   //struct of file information
extern uint8  FAT32_Enable;

struct FileInfoStruct FileInfo;//ÎļþÐÅÏ¢

struct direntry MusicInfo;	//Òª²¥·ÅµÄmp3ÎļþÐÅÏ¢		//the mp3 file item whichi will be played
uint16 totalsongs;			//×ܵÄÒôÀÖÎļþÊýÄ¿			//total songs in the root directery on the SD card
uint8 type;					//ÎļþÀàÐÍ					//file type

uint8 track[128];			//stroe the information of songs (bit set indicate songs has been played)

void ClearTrackInfo()		//cleare the array track[128]
{
	uint8 i;
	for(i=0;i<128;i++)track[i] = 0;
}

uint8 SetTrack(uint16 songs)//set the track bit, return 1 means the song has been played
{
	uint8 byte_offset;
	uint8 bit_offset;
	songs--;
	byte_offset = songs/8;
	bit_offset = songs%8;
	if(track[byte_offset] & (1<<bit_offset))return 1;
	else
	{
		track[byte_offset] |= 1<<bit_offset;
		return 0;
	}
}

void Delay(uint16 n)//ÑÓʱ
{
	while(n--)asm("nop");
}

//Timer initialization offer seed of the srandom()
void Timer1_Initial()
{
 TCNT1H=0x00;
 TCNT1L=0x00;
 TCCR1B=0x01;//system clock;
 ICR1H=0xff;
 ICR1L=0xff;
}

void PlayMusic()//²¥·ÅÒôÀÖº¯Êý£¬Ò»µ©Ö´Ðв»»áÍ˳ö
{
	uint16 keylen;			//ÓÃÓÚ¼ü´¦Àí		//for key processing
	uint16 count;			//Êý¾Ý¼ÆÊý			//data counting
	uint8 i;				//Ñ­»·±äÁ¿			//loop variable
	uint16 j;				//Ñ­»·±äÁ¿			//loop variable
	uint32 p;				//´Øָʾֵ			//cluster
	uint32 totalsect;		//ÎļþÓµÓеÄÉÈÇøÊý	//cotain the total sector number of a file
	uint16 leftbytes;		//Ê£Óà×Ö½Ú			//cotain the left bytes number of a file //the last cluster usually not fully occupied by the file
	uint8 *buffer;			//»º³å				//buffer
	uint32 sector;			//ÉÈÇø				//recor the current sector to judge the end sector
	uint8 flag;				//²¥·Å/ÔÝÍ£±êÖ¾		//flag of pause
	uint16 vol=DefaultVolume;//³õʼÒôÁ¿£¬Ó¦Óëvs1003º¯ÊýÀïµÄ³õʼÒôÁ¿Ïàͬ	//default volume
	uint16 songs=1;			//ĬÈϷŵÚÒ»Ê׸è	//play the fist songs by default
	uint8 mode=DEFAULT_MODE;//µ¥ÇúÖظ´			//repet all by default
	uint16 songs_cnt = 0;					//how many songs have been played
	if(totalsongs==0)return;//Èç¹ûûÓиèÇúÔòÒì³£Í˳ö	//if no music file return
	uint32 rand_val;
	Timer1_Initial();//Æô¶¯¶¨Ê±Æ÷£¬ÓÃÓÚ²úÉúËæ»úº¯ÊýµÄÖÖ×Ó	//initialize the timer
	ClearTrackInfo();
next://ÏÂÒ»Ê׸èµÄÆðʼµØ·½						//label for "goto"
	if(mode==RANDOM)//Ëæ»ú²¥·Å¸èÇú 				//if the mode is shuffle the songs
	{
		songs_cnt++;
		if(songs_cnt == totalsongs && totalsongs<1025)
		{
			ClearTrackInfo();
			songs_cnt = 0;
		}
		rand_val = TCNT1;
		Delay((random() && 0x00ff));
		rand_val <<= 16;
		rand_val += TCNT1;
		srandom(rand_val);
		if(totalsongs>1024)
		{
			songs = (uint16)(((random()/214749)*(uint32)totalsongs)/10000)+1;//Ëæ»ú²úÉú¸èÇúÐòºÅ	//create random song number
		}
		while(totalsongs<1025)
		{
			songs = (uint16)(((random()/214749)*(uint32)totalsongs)/10000)+1;//Ëæ»ú²úÉú¸èÇúÐòºÅ	//create random song number
			if(SetTrack(songs) == 0)break;
		}	
	}
	count=0;//Çå»ùÊý	//clear count
	flag=1;
	while(count<2048 && (type != MID))//recommand 2048 zeros honoring DREQ befor soft reset
	{									//ÓÃÓÚ´ÓwmaÌø³öµ½ÏÂÒ»Ê׸裬ºÍÒ»Ê׸è½áÊøÌî³äÊý¾Ý//midi¸ñʽ²»ÐèÒª
		if((VS1003B_PIN & _BV(VS1003B_DREQ))!=0)
		{
			for(j=0;j<32;j++)
			{
				VS1003B_WriteDAT(0x00);//Ìî³ä0	//fill 0
				count++;
			}
			if(count == 2047)break;
		}
	}
	VS1003B_SoftReset();//soft reset //in case of playing wma files//Èí¼þ¸´Î»
	Search(PATH,&MusicInfo,&songs,&type);		//ÕÒµ½ÏàÓ¦µÄÎļþ		//find the file
	p     = MusicInfo.deStartCluster+(((uint32)MusicInfo.deHighClust)<<16);//¶ÁÎļþÊ×´Ø	//the first cluster of the file
		
	totalsect = MusicInfo.deFileSize/512; //¼ÆËãÉÈÇøÊý			//calculate the total sectors
	leftbytes = MusicInfo.deFileSize%512; //¼ÆËãÊ£ÓàµÄ×Ö½ÚÊý	//calculate the left bytes	
	i=0;
	sector=0;
	
	while(1)
	{
		keylen=0;
    	for(;i<SectorsPerClust;i++)		//Ò»¸ö´Ø	//a cluster
		{
			buffer=malloc(512);
			FAT_LoadPartCluster(p,i,buffer);//¶ÁÒ»¸öÉÈÇø	//read a sector
			count=0;
			while(count<512)
			{
				if(flag==0){if(keylen){Delay(100);keylen--;}}
				else if(type == MID){if(keylen){Delay(100);keylen--;}}
				if((VS1003B_PIN & _BV(VS1003B_DREQ))!=0 && flag)	//¸ù¾ÝÐèÒªËÍÊý¾Ý  //send data  honoring DREQ
				{
					for(j=0;j<32;j++)			//ÿ´ÎËÍ32¸öÊý¾Ý		//32 Bytes each time
					{
						VS1003B_WriteDAT(buffer[count]);
						count++;
					}
					if(keylen)keylen--;			//ÓÃÓÚ¼ü´¦Àí			//for key processing
					if(sector == totalsect && count >= leftbytes)		//Èç¹ûÎļþÒѽáÊø		//if this is the end of the file
					{
						if(type == MID)//waiting the midi file was decoded
						{//¶ÔÓÚmidÒôÀÖÒª½Ó×ÅËÍ2048¸öÁã
							count=0;
							while(count<2048)//recommand 2048 zeros honoring DREQ goto next songs
							{
								if((VS1003B_PIN & _BV(VS1003B_DREQ))!=0 )
								{
									for(j=0;j<32;j++)
									{
										VS1003B_WriteDAT(0x00);
										count++;
									}
									if(count == 2047)break;
								}
							}
						}
						i=SectorsPerClust;
						break;
					}//Îļþ½áÊø			//file ended
					if(count == 511){break;}//512×Ö½ÚËÍÍêÌø³ö		//break if a sector was sent
				}
				if((PIND&STOP)==0 /*&& keylen==0*/)//²¥·ÅÔÝÍ£¼ü		//key PLAY/PAUSE
			    {
	 			    Delay(100);
					if(!(PIND&STOP))
					{
						while(!(PIND&STOP));
						 if(flag)flag=0;
						 else flag=1;
						 Delay(1000);
					 }
				 }
				else if(!(PIND&DOWN) && keylen==0)  //ÒôÁ¿-			//Volume down
	 			{
				    Delay(100);
	   			 	if(!(PIND&DOWN))  
					{
					keylen=200;
					   vol=vol+((uint16)(1<<8)+1);
					   if(vol>=0xFEFE) vol=0xFEFE; 
	   			       else VS1003B_WriteCMD(0x0b,vol);
					 }
	 			 }
				 else if(!(PIND&UP) && keylen==0) //ÒôÁ¿+			//Volume up
	  			 {
					 Delay(100);
				 	 if(!(PIND&UP)) 
					 {
					 keylen=200;
					   vol=vol-((uint16)(1<<8)+1);
					   if(vol<=0x0101) vol=0x0101;
					   else VS1003B_WriteCMD(0x0b,vol);
	   			     }
				  }
				 else if(!(PIND&NEXT)) //ÏÂÒ»Ê×						next songs
	 			 {
					Delay(0x7fff);		
					if(!(PIND&NEXT))
					{
						Delay(0x7fff);
						if(!(PIND&NEXT))
						{
							while(!(PIND&NEXT));
							songs++;
							if(songs > totalsongs)songs=1;
							{
								free(buffer);
							//	Delay(0xffff);
								goto next;
							}
						}
					}
	  			 }
				 else if(!(PIND&PREV)) //ÉÏÒ»Ê×						previous songs
	 			 {
					Delay(0x7fff);		
					if(!(PIND&PREV))
					{
						Delay(0x7fff);
						if(!(PIND&PREV))
						{
							while(!(PIND&PREV));
							if(songs == 1)songs=totalsongs;
							else songs--;
							{
								free(buffer);
							//	Delay(0xffff);
								goto next;
							}
						}
					}
	  			 }
				 else if((!(PIND&MODE)) && keylen==0) //ģʽ			//mode key
	 			 {
					Delay(100);		
					if(!(PIND&MODE))
					{
						keylen=0xffff;
						if(mode==REPET_ALL)
						{
							mode=REPET_ONE;
							LED1_ON();
							LED2_OFF();
						}
						else if(mode==REPET_ONE)//next mode is shuffle
						{
							mode=RANDOM;
							LED1_OFF();
							LED2_ON();
							srandom(((uint32)TCNT1)<<16);//²úÉúËæ»úÊýµÄÖÖ×Ó
						}
						else 
						{
							mode=REPET_ALL;
							LED1_OFF();
							LED2_OFF();
						}
					}
	  			 }
			}
			sector++;
			free(buffer);
		}
		i=0;
		p=FAT_NextCluster(p);//¶ÁÏÂÒ»´ØÊý¾Ý			//read next cluster
		if(p == 0x0fffffff || p == 0x0ffffff8 || (FAT32_Enable == 0 && p == 0xffff))//Èç¹ûÎÞºóÐø´ØÔò½áÊø£¬	//no more cluster
		{
				if(mode==REPET_ALL)songs++;
				if(songs>totalsongs)songs=1;
				goto next;
		}
	}
}

//main function
int main()
{
	uint8 retry = 0;

	DDRD &= 0x03;//³õʼ»¯¶Ë¿Ú
	PORTD |= 0xfc;
	
	LED1_CON();
	LED1_OFF();
	LED2_CON();
	LED2_OFF();


	OSCCAL = 0x00;//×îСRCÕñµ´ÆµÂÊ	//in order to operate some low speed card the initialization should run at lowest speed

	Delay(0xffff);

	MMC_SD_Init();//³õʼ»¯spi¿Ú		//SPI initialize

	Delay(0xffff);

	if(VS1003B_Init())
	{
		//LED1_ON();//ÅäÖÃVS1003	//config vs1003
		while(1)
		{
			LED1_ON();
			Delay(0xffff);
			LED1_OFF();
			Delay(0xffff);
		}
	}
	Delay(0xffff);//Ìṩ×ã¹»µÄÑÓʱ				//supply enough delay
	Delay(0xffff);
	Delay(0xffff);
	Delay(0xffff);
	Delay(0xffff);

	while(MMC_SD_Reset())//³õʼ»¯SD¿¨					//sd card initialize
	{
		retry++;
		if(retry>20)
		{
		//	LED2_ON();
			while(1)
			{
				LED2_ON();
				Delay(0xffff);
				LED2_OFF();
				Delay(0xffff);
			}
		}
	}

	OSCCAL = 0xff;//×î´óRCÕñµ´ÆµÂÊ				//normal operation maximum the frequency

	Delay(0xffff);								//wait for stable

	if(FAT_Init())//³õʼ»¯Îļþϵͳ Ö§³ÖFAT16ºÍFAT32	//initialize file system  FAT16 and FAT32 are supported
	{
	//	LED1_ON();
	//	LED2_ON();
	//	while(1);
		while(1)
		{
			LED1_ON();LED2_ON();
			Delay(0xffff);
			LED1_OFF();LED2_OFF();
			Delay(0xffff);
		}

	}
	Search(PATH,&MusicInfo,&totalsongs,&type);//ËÑË÷¸ùĿϵĸèÇú ²»°üº¬×ÓĿ¼
	//Ò²¿ÉÒÔÖ¸¶¨Îļþ¼Ð ÈçSearch("\\new\\mp3",&MusicInfo,&totalsongs,&type);
	//´ú±íÔÚ¸ùĿ¼ÏµÄnewÎļþ¼ÐϵÄmp3ÎļþϵÄÒôÀÖÎļþ

	//search the songs in the root directery on the SD card
	//You can also specify the directery where the songs are placed
	//eg: Search("\\new\\mp3",&MusicInfo,&totalsongs,&type);
	//		means search the file in the foler C:\new\mp3

	PlayMusic();//²¥·Å¸èÇú		//play songs
	while(1)
	{
		while(1)
		{
			LED1_ON();LED2_OFF();
			Delay(0xffff);
			LED2_ON();LED1_OFF();
			Delay(0xffff);
		}
	}
	return 0;
}

or songs play?

That sounds like you have a short circuit (i.e. a direct connection) between power and ground somewhere on your perfboard, which is sucking all the power from your regulator. It could be that some wires are cross-connected by mistake, or it could be that some exposed leads are touching or solder has flowed between two pads making an unintentional connection. In any case, you’ll need to find it and remove it.

Just to be sure, what resistance range was your multimeter set to when you took this measurement? Also, I forget, but does your multimeter have a continuity measuring mode that beeps when you touch connected points on a board? Does it beep when you connect the red lead to the VCC net and the black lead to ground? That’s a nice quick way to check if they’re still shorted.

-Adam

sorry i added to the last post after you replied…

i have found the problem, and a ba****d of a problem it is. it is whether the sd card is in or not, the circuit shorts! with my multimeter set at 2000 ohms and the sd card ejected, i get a reading off the scale i.e “1”

with the sd card in i get a reading of 0.
So it isnt MY immediate error, but it brings me to the question of why?

its any sd card!
they are also now damaged it think

That’s really weird! Do the GND and VCC tabs on your SD cards read as if they are shorted to each other?

-Adam

when the sd card is not plugged in, the vcc and gnd of the socket do not contact, but when i put my sd card in they do contact. i wonder whether i damaged the card another time, which shorted gnd and vcc on the card, and now this is my new error. i;ll check that tomorrow!

Ok I now have a new sd card, and the sd card i have been using before.

my multimeter is set on 2000 ohms.
with no sd card plugged in, vcc and gnd i get a resistance of 585.
with the old sd card plugged in i get a resistance of 0 ohms.
with the new sd card plugged in i get a resistance of 397 ohms.

the circuit is off - there is no power to it.

I think possibly somehwere along the line i ust have damaged the sd card somehow, but i am worried to turn the circuit back on with the new sd card in encase there is still an issue that is breaking the sd cards.

what d’you reckon???

That’s very odd. Before you try anything else you might check the power to ground resistance of your SD cards alone (i.e. out of the reader).

By the numbering scheme above, Pins 3 and 6 are ground, and Pin 4 is power. You should read very high resistance between the power and ground pins. If your old SC card shows 0 ohms between power and ground I would get rid of it, it might damage anything else you plug it into.

Other than that I’m not really sure what to do, except to check that every connection you’re making matches the schematic, and that you don’t have any unintentional connections like solder bridges. You might also power up your board with no SD card in it and see what voltages you read going to the SD card slot. Anything more than 3.6V would be bad news for your cards.

Good luck!

-Adam

Thanks Adam, will check all of that.
I am thinking of getting a proffesional to make me up a pcb, it will cost me £200 pounds, so at the moment I am going to hold out. But if i go ahead with it, would you mind if i sent you a copy of his diagram to check whether its correct?

Thanks

I would be happy to look over the diagram, but I can tell you from experience that some mistakes you only catch when you try to assemble the darn thing!

-Adam

I’m getting 0 ohm resistance on the sd card, suggesting its bust - but it wasnt when i bought it, so i dont know how that happened, unless theres another error in my circuitry somewhere.

and the voltage across the sd card reader is 3.27 volts without the card in, suggesting all is OK…

EDIT:
I have put new sd card in (at risk) to see what would happen, but nothing is happening - no leds on etc, but i wondered, between gnd and vcc of the sd reader without a card in it, there should be no voltage surely because there is not card to carry that voltage???

I have checked the voltages across the leds, and two of the three have VERY low voltages across them, like 0.27 and 0.73 volts… (checked because nothing lighting up).

In terms of the size of the voltages everywhere, I think we’re OK. nothing is getting a too higher voltage.

But when i plug the headphones in I just get that ol’ static sound…

I am trying to work out a way of testing whether the avr is running the program, but I wrote that short program above to turn the led on, and it turned on, so i cant see that being the issue.

Sorry last thin, just did a check on voltages across all the signal lines from the sd card to gnd and the vs1002 and gnd, and they all have voltages except the DREQ line, which is th line that an led is on, and flashes when signal is traelling down it. Could this stop a song playing???

last last last thing, the connections to the headphone jack, left gbuf and right, do they ALL need to be connected or is it OK to just have left and GBUF connected?

Yes, when you have the power turned on you should see (close to) the same voltage between the power and ground pins of your SD card socket, whether or not the SD card is in the socket. It’s when you see little or no voltage between these pins that you’re in trouble, because that indicates they are being connected together.

A quick scan of the datasheet makes me think that the DREQ pin should be coming high unless there is a problem with your circuit, or the AVR is doing something to hold it low (which could be back for the VS1002!). This could be why the mp3 playing program isn’t operating though, since the DREQ line going high is what tells the AVR to continue sending instructions.

When you had your setup playing files on the breadboard, did your DREQ LED turn on right away? You might try erasing the code on the AVR and seeing if the LED will turn on. You could also try disconnecting this LED. If that fixes it, you could even bring it back in with a bigger resistor (you’re using a 1Kohm resistor with it now, right?).

And yes, having just left and GBUF connected to a socket should work fine, you should hear only the left stereo channel of your mp3s (or all of the audio if you have mono mp3s).

-Adam

when i had the breaboard setup, the dreq light came on immediately yes. then it flashed as the data went along the dreq line - like what you mentioned about the matrix remember.

do you mean erase the avr, then write a small program to turn the dreq led on?

the resistors are about 500 ohms on the leds. what do you mean disconnecting the led. not having an led in the circuit?

I thought that it wouldnt make any difference about left and gbuf. so it must be my dreq problem… i’ll check the connection again, but i’m pretty sure the physical circuit is OK…

i dont remember chaning the ode in anyway except the speed of the vs1002 to compensate for the vs1002, when it was on breadboard, so i cant see that being the problem…

I don’t think this is the source of your problem, I was just curious if the LED you were using to watch the signal might be interfering with it. When you use an LED as a diagnostic tool to watch a digital signal line you’ll probably want at least a 1Kohm resistor in series with it. With a smaller resistor (like one you would normally use with an LED on a dedicated line), an LED can draw too much current and might actually interfere with the signal, depending on how much current the signaling device can supply.

-Adam

I’ll try it, but the schematic suggests 510 ohm and i think i would hav used that on the breadboard which did work

right i tried the following program

#include <avr/io.h>
int main( void )
        {
DDRD |= (1<< PD2);
DDRC |= (1<< PC1);
DDRB |= (1<< PB1);
while(1)
{
		while(PIND&(1<<PD2))
		{
		}

		PORTC |= (1<< PC1);
		PORTC |= (1<< PC5);
		PORTB |= (1<< PB1);
}
   return 1;

        }

now the pind pd2 doesnt do anything, i was trying to get it to be a button press and the lights would turn on, but that didnt work, the lights come on anyway BUT

with the program above only led2 on pin 15 comes on. not even led 1 on pin 28 comes on with the above program and nor does the dreq leg come on. does this tell us anything?

in terms of voltages from vcc to gnd there is 3.3 volts, on pin 15 where led 2 is and it is coming on, there is 3.19 volts. across pin 28’s led (actually across the leds legs missing out the resistor) is 3.26 volts (including the resistor) still 3.27 volts, and across the dreq led without resistor 1.99 volts including resistor 1.9 volts

i think this is going to make me look really stupid. I tested the program i poste above on a breadboard with leds in relevant places and they all came on - not program or avr.

then i looked at my circuit, I cut the led legs and soldered the resistors on. i therefore might have soldered them to the board the wrong way around, meaning they wouldnt come on… but if the circuit couldnt push a current down the led on DREQ, it wouldnt stop it pushing one down the DREQ line of the vs1002 would it???

I haven’t had a chance to look at your code yet (hectic at work right now), but no, a backwards LED wouldn’t light up, but it also wouldn’t keep the DREQ line low. There are a couple of ways you can check the polarity of an LED after cutting the leads (aside from powering it both ways and seeing if it lights up):

Aside from having the shorter leg, the negative side of the LED usually has a flat edge molded into it. Also, if you look at the metal plates inside the LED lens, the negative side is usually significantly larger.

-Adam

P.S. That picture is commonly set as the desktop background in the intro-electromechanical systems lab at my university.

thanks adam. sorry if work is busy and you are always here helpng me out. My LEDs are square, so i cant use the flat side as a way of telling which is cathode/anode!

The only other thing i wonder is whether the avr is trying to tell me an error, by flashing an led but cant because it is the wrong way around. i cant tell from the mp3 player code whether an error would stop the dreq going high (an error like no sd card).

if the error is a short circuit due to a solder hair crossing then i will never find it because i have looked and looked, and cant find one anywhere.

do you think £200 to have a circuit drawn up for me is expensive? it sounds a lot to me, considering its not surface mount, and not very complicated, and on top of that i then have to pay for the board to be made??

OK, I have turned the leds around and they all work with the program i wrote above. (red a little dodgy, give it a tap and i comes on.)

but something interesting is happening. if i then also plug the vs1002 breadboard in while the three leds are on, the dreq led goes off, if i then unplug it, the led comes back on, why is this affecting the led???

the dreq led is also dimmer?

Now I’m a little confused, I thought your breadboard was your only power supply, so how is the rest of your circuit already on when you plug it in?

I’m not surprised at what they want to charge you, but I do think that £200 (~$350?) is WAY too much to pay to have such a simple circuit drawn up for you, not even including manufacturing and assembly. Instead, why not pick up one of these guys, already designed assembled and tested, for $40.95 (more with international shipping, but still!):

Breakout Board for VS1002 MP3/SD Module

It has everything but the AVR on a board already, including step-up power converters to run everything off of a single AA battery. I haven’t compared it’s schematic to the one from your project in detail, but it looks like all the connections you would need to make to your AVR (including power for it) are brought out to the ten-pin connector. It looks like it even comes with a ribbon cable, so you could also grab one of these 10-pin header sockets to connect an to your avr circuit on a perfboard.

-Adam