CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

MMC card

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Dasat



Joined: 07 Feb 2012
Posts: 5

View user's profile Send private message

MMC card
PostPosted: Wed Feb 15, 2012 6:27 am     Reply with quote

I've been battling with this mmc code. I'm trying to interface it with PIC18F4520. I observed that it seems the card is not initiliazing at all, so I would like to clarify this before moving to reading and writing at all. Pls help me view the code and make any suggestions. Thanks.
I'm using the inbuilt mmc_spi.c.

Code:

#include <nokia3310driver.c>
#use delay (clock=20000000)

#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
#fuses HS,NOWDT,NOBROWNOUT,NOLVP

#define MMC_CS    PIN_C1
#define MMC_CLK   PIN_C3
#define MMC_DI    PIN_C4
#define MMC_DO    PIN_C5
#include <mmc_spi.c>

int i,display;
signed int16 ad;
char dat;
int16 size;
int8 data[64];
int *ptr;//pointer to array
int32 adres;


void main() {
adres = &data[0];
size = 8;
ptr = data;

SETUP_SPI(SPI_MASTER | SPI_CLK_DIV_64 | SPI_L_TO_H |SPI_XMIT_L_TO_H );
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1 ( T1_DISABLED | T1_DIV_BY_8 );

setup_timer_2(T2_DIV_BY_1,199,5);   
     
initlcd();
mmc_init();

if (mmc_init()==0)
  putlcdchar("mmc init succ");
else
  putlcdchar("mmc unsucces");

delay_us(100);


// put values in my array;

/*for (i=0; i<64; i++){
     data[i] = 1;
     }
for (i=0; i<64; i++){
   ad =mmc_write_block(adres, size, *ptr);
   if (ad==0)
     putlcdchar("write was successful");
   else
     putlcdchar("write was un");
   
   adres++;
}
dat = mmc_read_data();

}

_________________
Believe and u would see
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Feb 15, 2012 6:32 am     Reply with quote

Tell us what hardware you're using.
That's PIC, interface and mmc card specs.
Dasat



Joined: 07 Feb 2012
Posts: 5

View user's profile Send private message

PostPosted: Wed Feb 15, 2012 10:56 am     Reply with quote

I'm still working with simulation on ISIS not yet setting it up. But the PIC is 18F4520
_________________
Believe and u would see
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Feb 15, 2012 12:51 pm     Reply with quote

You will NEVER,EVER get the ISIS ( Proteus) simulation to work..

Can't be done, it is full of bugs,errors and faulty DRCs.

Get REAL hardware...program a REAL PIC, then and only then will it work.

BTW you CANNOT get a 5 volt PIC and a 3 volt SD card to work if they are the ONLY devices you have,NEVER,EVER going to happen.

well,maybe once, then the magic smoke comes out and you've destroyed both devices....
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sat Feb 18, 2012 3:55 am     Reply with quote

temtronic wrote:
You will NEVER,EVER get the ISIS ( Proteus) simulation to work..

Can't be done, it is full of bugs,errors and faulty DRCs.


Funny thing, one of my customers used my file system driver with Proteus. I like you said it will never work. I had to eat humble pie because he got it working. :-)
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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