Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

MMC multiple block write problem. (What is "BUSY" in the diagram i provided?)

Status
Not open for further replies.

vinodstanur

Advanced Member level 3
Joined
Oct 31, 2009
Messages
751
Helped
114
Reputation
234
Reaction score
114
Trophy points
1,333
Location
Kerala (INDIA)
Activity points
7,054
MMC multiple block write problem. (What is "BUSY" in the diagram i provided?)


Reading part is okay...I could read multiple blocks untill the card reads its entire memory.(64MB). Now,
I want to write blocks to MMC continously.(using CMD24) But after few blocks write, it is getting inside "error0" or "error1" loops.
I had written the write block code by looking on the above figure.(snap shoot from a hitachi MMC spec.
Code:
void write()//
	{
	count=0;
	/*write 512 blocks*/
	command(25,arg,0xff);
	while(readdata!=0){spi_read();printf("error0");}
g:	spi_write(0xff);
	spi_write(0xff);
	spi_write(0xfe);
	for(int g=0;g<512;g++)
		{
		ADGO=1;
		while(ADGO);
		spi_write(ADRESL);
		PORTD=ADRESL;//to see adc reading in 8 leds in PORTD
		}
	spi_write(0xff);
	spi_write(0xff);
	spi_read();
	while((readdata&0b00011111)!=0x05){spi_read();printf("error1");}
	while(readdata==0){spi_read();}
	goto g;
	}
Now i doubt some error in my code . I could'nt understand that "busy" in figure . What to do for that in program?

It says that,
 

Re: MMC multiple block write problem. (What is "BUSY" in the diagram i provided?)

hi upand_at_them, the link which you provided is exactly what i am searching for... Thanks for the link... Now i think i could solve my problem....
 


Re: MMC multiple block write problem. (What is "BUSY" in the diagram i provided?)

Solved....
Now i could read and write continuous 512 blocks with my PIC16F877A. Problem is the "stop token" in continuous write termination... I got the correct stop token as 0x11111101 from your first link. Thanks ...Now every thing is okay...
 

Re: MMC multiple block write problem. (What is "BUSY" in the diagram i provided?)

One thing I forgot to mention in your other thead is that you might be able to gain some extra time by having a small buffer. It can't be big, as you know, because of the limited RAM of the PIC16F877. But something like at least 20 bytes would be possible, maybe 100 or more. Under this scheme you'd use an interrupt to get a byte from the MMC and put it into the buffer and another interrupt for pushing a byte out the PWM. You'd have to keep track of how full the buffer is so that you don't read too much from the MMC and overwrite the buffer.
 

MMC voice recorder using PIC16F877A

but friend i am not getting the idea ie the advantage of using a buffer. Actually it got 256bytes of ram. I can define an array of about 100bytes. But i am confused what is the need of that in my case, because i am just reading the mmc from first sector to the last and after reading every byte i am sending it to PWM. Similarly i am writing each ADC reading to the MMC just after ADC is performed. Now the audio quality is also superb...
Then how could i increase efficiency by using RAM as a buffer? or what is the main advantage in my case?
 
Last edited:

Re: MMC multiple block write problem. (What is "BUSY" in the diagram i provided?)

Oh, I'm sorry, vinod. I thought you were looking to increase the audio quality even more. The buffer would allow the PWM writes to happen without interference from reading the MMC. Perhaps you have already achieved the full quality.

-Mike
 

Re: MMC multiple block write problem. (What is "BUSY" in the diagram i provided?)

This is my voice recorder which i made three days ago.
 

Re: MMC multiple block write problem. (What is "BUSY" in the diagram i provided?)

Very nice! I like it. Good quality too.
 

Re: MMC multiple block write problem. (What is "BUSY" in the diagram i provided?)

Very nice! I like it. Good quality too.
Yup i never expected this quality. But takes a lot of memory. But now i really want to read a 8bit mono wav file from a FAT formatted MMC. But i think i cant do it with this 877a. Right? And also, i think its really difficult to write code for file system accessing. So any library available for PIC16F877A for High Tech-C compiler? Which is the better pic in 18F(with enough ram and flash) series with same 40-pin configuration of PIC16F877A?
 

Re: MMC multiple block write problem. (What is "BUSY" in the diagram i provided?)

Obviously the best situation would be to get a microcontroller with much more RAM. Some Atmel microcontrollers have much more RAM than PIC chips. But you still might be able to do it with the 16F877.

Most other applications that access MMC/SD are probably reading the partition table, the FAT, and the directory into memory and then accessing it. And writing it back to the card when modified. You certainly can't do that, because of the limited RAM.

But you will be able to at least read the root directory and get the file's starting sector without using much RAM. After that it will be tricky. Because of the way FAT works, one entry refers to another entry that probably won't be in sequential order...this would require reading a sector and throwing away everything up to the part you need (because you have to read an entire sector of 512 bytes).

So I think what you have to do is find the file on the card and read all of the file's FAT locations into an array. This will limit the maximum file size to something like 25 sectors?...Or whatever space your PIC can afford. (I'm assuming each sector number takes up 4 bytes). Then move through the array, getting each sector from the card and sending it to the PWM.

I hope you can do it. My application was a data logger that created its own file of a fixed size on the MMC, which made the FAT handling much easier. I didn't allow files to be put onto the MMC from a computer. Instead, I erased the root directory each time the data logger was started and created a "new" file in the same location.

The only 18F I have used that has enough RAM is the 18F2455, but it is only a 28-pin chip. I haven't used any 40-pin 18F chips. And, actually, the only chips I've used with MMC/SD are: 16F628, 16F88, and 16F886.

If you can do this it will be a great achievement, because everyone else will tell you that you can't do anything on a MMC with a PIC that has only 256 bytes of RAM!

Mike
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top