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
yes i checked that link and got some idea...There after, i collected some more information about the mmc initialization via spi.SD / MMC card are SPI interfaced , it should not be a problem in interfacing it....
check this
**broken link removed**
#include<pic.h>
#define _XTAL_FREQ 20e6
#define CS RC2
unsigned char t,rec,dat,tempbuf,readdata;
unsigned int count;
void usrt_init()
{
TRISC6=0;
TXSTA=0b00100110;
RCSTA=0b11010000;
SPBRG=10;
}
void string(const char *p)
{
while(*p)
{
TXREG=*p;
while(TRMT==0);
p++;
}
}
void spi_init()
{
TRISC4=1;
RC2=0;RC3=0;RC5=0;
TRISC2=TRISC3=TRISC5=0;
SSPCON=0b00100000;
SSPEN=1;
SMP=1;
CKE=0;
CKP=1;
}
////////////////////////////////////////////////////
void spi_write()
{
SSPBUF=dat;
while(BF==0);
tempbuf=SSPBUF;
}
////////////////////////////////////////////////////
void spi_read()
{
SSPBUF=0xff;
while(BF==0);
readdata=SSPBUF;
}
////////////////////////////////////////////////////
////////////////////////////////////////////////////
void mmc_init()
{
CS=1;
CS=0;
dat=0xff;
spi_write();
dat=0x40;
spi_write();
dat=0x00;
spi_write();
dat=0x00;
spi_write();
dat=0x00;
spi_write();
dat=0x00;
spi_write();
dat=0x95;
spi_write();
spi_read();
count=0;
while((count<1000)&&(readdata!=0x01))
{
spi_read();
count++;
}
if(count>=1000)
{
string("FIRST ERROR");
}
else
{
CS=1;
CS=0;
dat=0xff;
spi_write();
dat=0x50;
spi_write();
dat=0x00;
spi_write();
dat=0x00;
spi_write();
dat=0x02;
spi_write();
dat=0x00;
spi_write();
dat=0xff;
spi_write();
spi_read();
count=0;
while((count<1000)&&(readdata!=0x01))
{
spi_read();
count++;
}
if(count>=1000)
{
string("SECOND ERROR");
while(1);
}
{
CS=0;
string("INITIALIZATION COMPLETE ");
}
}
}
main()
{
TRISD=0;
PORTD=0;
usrt_init();usrt_init();
spi_init();__delay_ms(10);
spi_init();__delay_ms(10);
spi_init();__delay_ms(10);
mmc_init();
while(1)
{
CS=0;
dat=0xff;
spi_write();
dat=0x58;
spi_write();
dat=0x01;
spi_write();
d:spi_read();
if(readdata==0x05){string("data write mode activated ");while(1);}
else {string("trying ");goto d;}
}
}
Hello,
Matrix Multimedia do a FAT and FAT32 driver inside the Flowcode software. This supports PIC, dsPIC, AVR and ARMSAM7S chips. I wrote the component and can provide help if needed.
2. Without buffer memory
The 16F877A by itself does not have sufficient memory, so there is a limit to how much data can be stored in the RAM (say 20 bytes). These 20 bytes of data could be written to the card, but then the remaining 492 bytes of data will have to be null. This means existing data in the card gets erased. You could avoid this problem by reading in the data first into the PICs RAM, but with limited RAM size you cannot read in all the data, so editing a MMC card using a 16F877A cannot be done.
thanks
a
So from where i could get those required data? I searched in google a lot but i couldn't find the exact initialization steps other than some CMD0,CMD1 etc etc......you should download a copy of the MMC specs first, all the commands required to access the card are given there. The specs also contain the initialisation procedure, ie: which command to send first etc.
Because official MMCA documents are available to members only, you may want to download a manufacturers product documentation from the internet, e.g. https://elinux.org/images/d/d3/Mmc_spec.pdf The SanDisk Manuals have been available from Sandisk directly, but apparently they are not longer trying to serve their customers.So from where i could get those required data?
If i am writing simply a letter say 'A' to all 512 bytes using a loop just for testing, then i think i could fill 512 bytes in MMC with 'A' .right?
And in reading case if i don't want to store the data in RAM , and if i would like to stream the data read data from the MMC byte by byte through USRT, then i think in my case, i could use PIC16F877A atleast for study purpose . Right?
Yes. Most drivers are however designed to support both types, because the differences are small. If you support both types, you'll identify the present card type in one place of the initialization dialog.both specs are different. Decide on which card you want to use MMC or SDCard.
both specs are different. Decide on which card you want to use MMC or SDCard.
How is the voltage translation from 5 to 3.3 V done ? Please post the schematic
There's possibly a misunderstanding about voltage translation. The transistor cicrcuit is good for the 3.3V power supply. But the 3 logic signals from µP to MMC also need voltage translation. Here a simple resistive divider (e.g. 2.2k:3.3k) will work at lower speeds. As far as I see, it should be at least sufficient for the speed achieved by a PIC16 without using hardware SPI.The 47 microF capacitor would slow the pulses down.
To start with use a simple resistor divider to bring down the voltage to 3.3 V
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?