View previous topic :: View next topic |
Author |
Message |
wATAw
Joined: 25 Feb 2008 Posts: 3
|
|
Posted: Wed Mar 12, 2008 11:38 am |
|
|
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
|
|
Posted: Wed Mar 12, 2008 4:22 pm |
|
|
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
|
|
Posted: Thu Mar 13, 2008 3:12 am |
|
|
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.
Thank you! |
|
|
wATAw
Joined: 25 Feb 2008 Posts: 3
|
|
Posted: Thu Mar 13, 2008 5:20 am |
|
|
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
|
|
Posted: Thu Mar 13, 2008 10:44 am |
|
|
Haven't used software SPI at all, so can't help. |
|
|
gremi
Joined: 11 Mar 2008 Posts: 20 Location: Toulouse, France
|
|
Posted: Fri Mar 14, 2008 8:15 am |
|
|
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
|
|
Posted: Fri Mar 14, 2008 10:29 am |
|
|
Works for both SD and MMC and will even tell you which you inserted! |
|
|
gremi
Joined: 11 Mar 2008 Posts: 20 Location: Toulouse, France
|
|
Posted: Fri Mar 14, 2008 10:35 am |
|
|
thanks |
|
|
xokolatecake
Joined: 09 Mar 2007 Posts: 14
|
|
Posted: Mon Mar 17, 2008 6:32 am |
|
|
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
|
WriteSector |
Posted: Sun Mar 30, 2008 4:17 am |
|
|
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
|
|
Posted: Wed Apr 02, 2008 12:19 pm |
|
|
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
|
|
Posted: Sat Apr 05, 2008 4:02 am |
|
|
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.
Some idea?
Thanks! |
|
|
Ivanovitx
Joined: 28 Jan 2007 Posts: 3
|
|
Posted: Tue Apr 29, 2008 10:53 am |
|
|
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
|
make a directory on MMC |
Posted: Mon Sep 15, 2008 8:03 pm |
|
|
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
|
|
Posted: Sun Jan 11, 2009 5:17 pm |
|
|
Hello
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 |
|
|
|