View previous topic :: View next topic |
Author |
Message |
Guest
|
My mmc can't save information!!! |
Posted: Fri Nov 07, 2008 3:04 am |
|
|
Hi
I wrote this code with the mmcsd.c library, but I don't know why it doesn't work.
Code: | #include "mmc.h"
#include "mmcsd.c"
#include "input.c"
void main()
{
char str[100];
byte a;
char T;
int16 i;
mmcsd_init();
delay_ms(500);
if (mmcsd_init())
{
printf("Could not init the MMC/SD!!!!");
while(TRUE);
}
while(1)
{
printf("READ OR WRITE???:-->\r\n");
T=getc();
putc(T);
if (T=='w')
{
printf("\r\nYour Text:\r\n");
get_string(str, 20);
for(i=0;i<=60;i++)
{
mmcsd_write_byte(i,str[i]);
delay_ms(1);
}
mmcsd_flush_buffer();
printf("\r\nwrite finished!!\r\n");
}
if (T == 'r')
{
for(i=0;i<=1000;i++)
{
mmcsd_read_byte(i,&a);
printf("%c",a);
}
mmcsd_flush_buffer();
printf("\r\n");
}
}
} |
For example in this code I write 'w' to write a string with 20 character length. I do it and write 'r' for read and it works very well. But when I want to read this string from MMC for a second time, the PIC returns NULL characters.
I tested the "ex_mmcsd.c" example and I get same result. Do you know where the problem is, and what's the correct way ? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri Nov 07, 2008 11:53 am |
|
|
Always post your compiler version number.
Most likely you have a problem in the hardware connection to the MMC/SD card. Expand your program to show the result of the mmcsd_flush_buffer() call, if this is unequal to zero you have a hardware problem.
There are at least two problems with the CCS mmcsd driver in v4.077.
Check out some hints in this thread |
|
|
Guest
|
|
Posted: Tue Nov 11, 2008 11:15 am |
|
|
I use 4.057.
But I can't get result and simulate it with Proteus. |
|
|
|