View previous topic :: View next topic |
Author |
Message |
harrie215
Joined: 15 Apr 2005 Posts: 6 Location: Netherlands
|
Transcend MMC to 16F877A |
Posted: Fri Apr 15, 2005 4:00 am |
|
|
I use a Transcend 32mb MMC (multimediacard).
Where should I connect the in and out to.
Should I connect PIN_B0 (in) to pin 2 (cmd) and
connect PIN_B3(out) to pin 7 (dat)?
And where do I connect PIN_B2 (mmc_cs) to?
Transcend pinout
1 RSV NC No connection
2 CMD I/O/PP/OD Command/Respon
3 VSS1 S Ground
4 VCC S Power supply
5 CLK I Clock
6 VSS2 S Ground
7 DAT I/O/PP Data
CCS MMC file
#define MMC_CLK PIN_B1
#define MMC_DI PIN_B0
#define MMC_DO PIN_B3
#define MMC_CS PIN_B2 |
|
|
steve_st23
Joined: 09 Sep 2003 Posts: 6
|
|
Posted: Fri Apr 15, 2005 4:08 am |
|
|
MMC pin1 is CS in SPI mode.
pin1-->CS
pin2-->SDI
pin5-->CLK
pin7-->SDO |
|
|
harrie215
Joined: 15 Apr 2005 Posts: 6 Location: Netherlands
|
Re: Transcend MMC to 16F877A |
Posted: Sat Apr 16, 2005 10:56 am |
|
|
harrie215 wrote: |
CCS MMC file
#define MMC_CLK PIN_B1
#define MMC_DI PIN_B0
#define MMC_DO PIN_B3
#define MMC_CS PIN_B2 |
Which pins should be pulled up by a 4K7 resistor?
Is this called SPI or MMC mode?
I use the CCS library. I don't need fat, I just read and write some information. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Apr 17, 2005 9:12 am |
|
|
steve_st23 wrote:
Quote: | MMC pin1 is CS in SPI mode. |
harrie215 wrote:
Quote: | Is this called SPI or MMC mode? |
Sigh......
For all other questions I recommend you acquire an MMC manual. The official MMC manual was free for download until about a year ago, then policies changed and now it is only available to members. From the official website non-members can only download the v3.31 Table of Contents which is useless. Still, the slightly older and previously free v3.1 specification can be found on many other websites. Use Google with the exact keywords: "MultiMediaCard system specification" pdf |
|
|
harrie215
Joined: 15 Apr 2005 Posts: 6 Location: Netherlands
|
|
Posted: Sun Apr 17, 2005 11:48 am |
|
|
Couldn't find that file. Found some other usefull stuff do.
De di and do should be pullup by min 50k0 to max 100K0.
I'm going to start with 91k0.
CS and clock can be connected straight. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Apr 17, 2005 3:34 pm |
|
|
The V3.1 MMC specification can be downloaded here
Just another small hint so you won't make the same mistake I made: The SDO from the PIC is to be connected to the SDI from the MMC and vice versa. |
|
|
harrie215
Joined: 15 Apr 2005 Posts: 6 Location: Netherlands
|
|
Posted: Mon Apr 18, 2005 8:47 am |
|
|
concerning driverfile mmc_spi.c
Has anybody got a small piece of code how to use this library.
My biggest problem is with the *ptr, how to use it.
I also get a Subscript out of range on line 275 as I compile it.
The MMC_BLOCK_SIZE of 512 doesn't work, if I put it to 100 (only in the concerning function modify) it compiles fine.
But I only want to use read and write_block functions, so that's not a real problem for me. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Apr 20, 2005 2:19 am |
|
|
Quote: | concerning driverfile mmc_spi.c
Has anybody got a small piece of code how to use this library.
My biggest problem is with the *ptr, how to use it. | 'int *ptr' is basic C code.... It is a pointer to a memory location containing integers.
Exampe: Code: | main()
int MyBuf[10];
int32 Address;
int16 Size;
MyBuf[0] = 'a';
MyBuf[1] = 'b';
MyBuf[2] = 'c';
MyBuf[3] = 0;
Address = 0x00001234;
Size = 4;
mmc_modify_block(Address, Size, MyBuf);
} |
Quote: | I also get a Subscript out of range on line 275 as I compile it.
The MMC_BLOCK_SIZE of 512 doesn't work, if I put it to 100 (only in the concerning function modify) it compiles fine.
But I only want to use read and write_block functions, so that's not a real problem for me. | As you already figured out the compiler error is caused by a shortage of RAM in your processor (a lousy error description).
Decreasing the value for MMC_BLOCK_SIZE will make your code compiler, but fail to function!
Most MMC and SD cards have an internal block size of 512 bytes, future cards of 2Gb+ will even have larger block sizes. This means that when you want to change even a single byte you first have to read the whole 512 byte block, change the byte in RAM and then write back the whole block again. This poses a large problem for some of the smaller PIC processors with little RAM !!
Which processor are you using?
Solutions to the RAM shortage are:
1) Add external RAM, for example FRAM with I2C interface.
2) Use another memory card type, for example compact flash (?)
3) Another processor... |
|
|
Guest
|
|
Posted: Wed Apr 20, 2005 6:36 am |
|
|
I'm using a 16f877A. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Apr 20, 2005 7:32 am |
|
|
Anonymous wrote: | I'm using a 16f877A. | Which has 368 bytes of RAM.
Reading the MMC cards can be done bytewise, but writing only in blocks of 512 bytes. You have a problem...
If possible, I recommend you to use another chip with more RAM.
Otherwise you can apply a trick by only using part of the 512 bytes block, for example the lower 300 bytes and fill the rest with hard coded zeroes. This is a waste of storage capacity, but MMC cards are cheap. It does however require a rewrite of the MMC libraries. |
|
|
|