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 support@ccsinfo.com

Another MMC Over SPI FAT32 code!
Goto page Previous  1, 2, 3, 4, 5, 6  Next
 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
wATAw



Joined: 25 Feb 2008
Posts: 3

View user's profile Send private message

PostPosted: Wed Mar 12, 2008 11:38 am     Reply with quote

Hey,
I am trying to run this library in a 18F2550, but i only manage to work MMCInit(). When i try to write any file, the SD lose the format, so i think it writes something, but it writes wrong.
Do you know what it could be?

I use 1k resistors and 3.3 zener diodes in SCL,CS and SDO. And a 100k pull-up resistor in SDI.

Thank you very much!!
BLL



Joined: 11 Nov 2006
Posts: 181
Location: Birmingham, UK

View user's profile Send private message

PostPosted: Wed Mar 12, 2008 4:22 pm     Reply with quote

Some routines increase the clock speed after switching the card into SPI mode. If the clock is too fast you will have problems! I need div64 on a 2620 using a 20MHz oscillator in HS mode. Any less and it doesn't work.
wATAw



Joined: 25 Feb 2008
Posts: 3

View user's profile Send private message

PostPosted: Thu Mar 13, 2008 3:12 am     Reply with quote

do i have to use a clock divisor if i am using software SPI? I thought the clock divisor only was for hardware SPI, but i am trying with it. Wink
Thank you!
wATAw



Joined: 25 Feb 2008
Posts: 3

View user's profile Send private message

PostPosted: Thu Mar 13, 2008 5:20 am     Reply with quote

When i try with the example of the library, it show this message:
MMC Initialized
Error 1st file in list was probably a dir.

Also when i try to write the sd, sometimes it lose the format....
I donĀ“t know what could it be.....can someone, who has it working with a 18f2550/18f4550, help me??
BLL



Joined: 11 Nov 2006
Posts: 181
Location: Birmingham, UK

View user's profile Send private message

PostPosted: Thu Mar 13, 2008 10:44 am     Reply with quote

Haven't used software SPI at all, so can't help.
gremi



Joined: 11 Mar 2008
Posts: 20
Location: Toulouse, France

View user's profile Send private message

PostPosted: Fri Mar 14, 2008 8:15 am     Reply with quote

Is it possible to use this driver for a SD card or is it just for MMC ?

thanks
BLL



Joined: 11 Nov 2006
Posts: 181
Location: Birmingham, UK

View user's profile Send private message

PostPosted: Fri Mar 14, 2008 10:29 am     Reply with quote

Works for both SD and MMC and will even tell you which you inserted!
gremi



Joined: 11 Mar 2008
Posts: 20
Location: Toulouse, France

View user's profile Send private message

PostPosted: Fri Mar 14, 2008 10:35 am     Reply with quote

thanks Smile
xokolatecake



Joined: 09 Mar 2007
Posts: 14

View user's profile Send private message

PostPosted: Mon Mar 17, 2008 6:32 am     Reply with quote

When you read the fat table address you reverse the order of the bytes, why is that? does that apply to everything that is read from the card?


thanks=)
entc_610



Joined: 30 Mar 2008
Posts: 1

View user's profile Send private message

WriteSector
PostPosted: Sun Mar 30, 2008 4:17 am     Reply with quote

hey! in the initial part of the forum here, it was mentioned that there was some error in the WriteSector, and it was corrected....i havent been able to find it, though.... it would be of great help if someone posted the changes...

waiting in anticipation....
Ivanovitx



Joined: 28 Jan 2007
Posts: 3

View user's profile Send private message

PostPosted: Wed Apr 02, 2008 12:19 pm     Reply with quote

Hi, I have the same problem than wATAw

When i try with the example of the library, it show this message:

MMC Initialized
Error 1st file in list was probably a dir.


I'm working on a pic18F258 with a 512MB micro SD card and a micro SD to SD adapter on port A.

Here is the code that I've modified:

/ Change the port to whatever port you are going to use
#use FAST_IO(a)
// Change this to set the right tris for your pins
#define SET_MMC_TRIS() set_tris_a(0b0001000) // 0b0001000 1=input,0=output
// Change these pins to whatever pins you are using
#define ChipSel pin_A0 // Chip-Select pin
#define ChipClk pin_A2 // SPI-Clock pin
#define ChipDout pin_A1 // SPI-Data out pin
#define ChipDin pin_A3 // SPI-Data in pin


Can someone help us?

Lots of thanks!

Ivan[/code]
Ivanovitx



Joined: 28 Jan 2007
Posts: 3

View user's profile Send private message

PostPosted: Sat Apr 05, 2008 4:02 am     Reply with quote

Now, I'm trying with a MMCplus card Transcend 512MB, but the results are the same than SD card:

MMC Initialized
Error 1st file in list was probably a dir.


Crying or Very sad Some idea?

Thanks!
Ivanovitx



Joined: 28 Jan 2007
Posts: 3

View user's profile Send private message

PostPosted: Tue Apr 29, 2008 10:53 am     Reply with quote

I test with an MMC 128MB card and now appears the message:
MMC init failed!


Somebody has this code working??

Thanks!
denkov



Joined: 19 Dec 2005
Posts: 2

View user's profile Send private message ICQ Number

make a directory on MMC
PostPosted: Mon Sep 15, 2008 8:03 pm     Reply with quote

10X Miniman
10X TOMY
Is a great job !

How can i use this code to make a directory?
ShellTox



Joined: 25 Jul 2007
Posts: 16

View user's profile Send private message

PostPosted: Sun Jan 11, 2009 5:17 pm     Reply with quote

Hello Very Happy


I'm trying to use a 512MB Mobile MMC card and a PIC18F4550 to build a data logger. I'm able to initiate the MMC and the FAT (I'm using a 16x2 LCD to see some debug messages).

I'm trying to use the first example in the .c which appends some text to the EVENTs.LOG file. The program runs until the end, but when I read the card in my pc the EVENTS.LOG remains the same.

I've formated my card with FAT32, with 512bytes per sector. I've created a .txt and altered the name and extension to EVENTS.LOG. Then I copied this file to the MMC card. I've also changed the .c to comply my hardware:

Code:


// Change the port to whatever port you are going to use
#use FAST_IO(A)
// Change this to set the right tris for your pins
#define SET_MMC_TRIS() set_tris_a(0b0000100) // 0b0001000 1=input,0=output
// Change these pins to whatever pins you are using
#define ChipSel      pin_A5 // Chip-Select pin
#define ChipClk      pin_A4 // SPI-Clock pin
#define ChipDout       pin_A3 // SPI-Data out pin
#define ChipDin      pin_A2 // SPI-Data in pin



The Data out from pic is connected to data in from card;
The Data in from pic is connected to data out from card.


My main follows:

Code:


#include <18F4550.h>
#include <string.h>
#include <MMC_SPI_FAT32.h>


#fuses HS,NOWDT,NOPROTECT,BROWNOUT,NOLVP,NOCPD
#use delay(clock=20000000)   
#ZERO_RAM
#include "flex_lcd.c"
#include "MMC_SPI_FAT32.c"


//+++++++++++++++++++++++++++++++++++++++++++++++++++
void setup(){
   lcd_init();
   if(MMCInit() == MMC_OK)  {
       printf(lcd_putc,"MMC init OK\n");
      delay_ms(1000);
      InitFAT();
      printf(lcd_putc,"FAT init OK\n");
      delay_ms(1000);
      printf(lcd_putc,"\f");
   }

}
//+++++++++++++++++++++++++++++++++++++++++++++++++++

void main(){
   
   char f,gfilename[12];
   char * msg;
   setup();
           
      strcpy(gfilename,"EVENTS.LOG");               
      f = fopen(gfilename,'a'); // open EVENTS.LOG for append     

   if (f & MMC_ERROR)                                           
      {                                               
      printf(lcd_putc,"Couldn't open file!\n");         
      if(f == MMC_NO_CARD_INSERTED)                           
         printf(lcd_putc,"Please, insert MMC!");                         
      else if(f == MMC_MAX_FILES_REACHED)                   
         printf(lcd_putc,"ops.. =)");                                   
   }                                                 
   else                                                         
   {       
      printf(lcd_putc,"\f");
      printf(lcd_putc,"START Writing\n");
      delay_ms(1000);


      strcpy(msg,"Written!");                         
      printf(lcd_putc,msg);
      fputstring(msg,f);
      fclose(f);
      delay_ms(1000);   
      printf(lcd_putc,"\nEND Writing");                                             
   }                     
                                   


}
//+++++++++++++++++++++++++++++++++++++++++++++++++++



At this point I don't know what to try next, because the EVENTS.LOG doesn't change.

Can anyone help me resolve this problem? I've read all this thread and I think I'm in the same step as incubus22 was in the middle of page 3.

Thank you
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 4 of 6

 
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