|
|
View previous topic :: View next topic |
Author |
Message |
mrYalamen
Joined: 13 Aug 2011 Posts: 9 Location: Viet Nam
|
Need help about interface with MMC card 18F4620 |
Posted: Fri Aug 26, 2011 12:07 am |
|
|
Hello all!
I'm a beginner of CCS. I had used "mmc_spi.c" from CCS library and used the function mmc_init() but it always respond "1"= failed! Can somebody give me the reason and solve this problem for me? Thank all. <Sorry about my English>
Here is my simple code
Code: |
#include "18F4620.h"
#fuses HS,NOWDT,NOPROTECT,NODEBUG
#use delay(clock=4000000)
//#include "input.c"
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
//#include "input.c"
#include "mmc_spi.c"
#include <stdio.h>
void main()
{
BYTE value,cmd;
int32 address;
int1 check;
// int8 i;
printf("\r\nCheck MMC Card\n\r");
check=mmc_init();
if(check==1)
{
printf("Check Card Failed\n\r");
}
if(check==0)
{
printf("Check Card Sucessful\n\r");
}
} |
|
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri Aug 26, 2011 3:47 am |
|
|
Many things can be wrong, but here is at least one error to fix: Code: | int1 check;
...
check=mmc_init(); | If you look in the file mmc_spi.c you will see the mmc_init function returns an enum of the type MMC_EC. This will not fit into an int1 !
Change your code to something like: Code: | #include "18F4620.h"
#fuses HS,NOWDT,NOPROTECT,NODEBUG
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8, ERRORS)
#include "mmc_spi.c"
void main()
{
MMC_EC check;
printf("\r\nCheck MMC Card\n\r");
check = mmc_init();
if (check == MMC_EC_OK)
{
printf("Check Card Sucessful\n\r");
}
else
{
printf("Check Card Failed\n\r");
}
for(;;);
} |
Note that I also added the ERRORS directive to the '#use rs232' line, this will reset some errors in the hardware UART when necessary. |
|
|
mrYalamen
Joined: 13 Aug 2011 Posts: 9 Location: Viet Nam
|
|
Posted: Fri Aug 26, 2011 9:21 am |
|
|
Thanks a lot for your helpful! Just because I'm too negligent. I only see the function that does not care about the return values and void main's details. I'll try it more! |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|