Hello Alexandar,
Thank you for your reply,
I tried to do with Mmc_Init () but all the same, no change.
I use XT oscillator 8MHz. I'll send you the entire code to watch. Yesterday I managed to initialize the card, and everything is working ok, but when I tried to re-initialize the card is not wanted, and still will not.
Code: Select all
#include <built_in.h>
unsigned short mmc_error;
unsigned short loop;
char file_contents[8]="struja";
char filename[14] = "STRUJAxTXT";
void M_Create_New_File() {
filename[6] = 'A';
Mmc_Fat_Assign(&filename, 0xA0); // Will not find file and then create file
Mmc_Fat_Rewrite(); // To clear file and start with new data
for(loop = 1; loop <= 99; loop++) { // We want 5 files on the MMC card
file_contents[0] = loop / 10 + 48;
file_contents[1] = loop % 10 + 48;
Mmc_Fat_Write(file_contents, 42); // write data to the assigned file
}
}
void main(){
TRISA=0X00;
TRISB= 0X00;
TRISC=0X13;
PORTB=0XF0;
ADCON1 |= 0x0F; // Configure AN pins as digital
CMCON |= 7;
Delay_100ms();
Spi_Init_Advanced(MASTER_OSC_DIV64, DATA_SAMPLE_MIDDLE, CLK_IDLE_HIGH, LOW_2_HIGH);
Delay_100ms();
PORTB=0XA0;
Delay_100ms();
while(1) {
if (!Mmc_Fat_Init(&PORTC,0)) {
PORTB=0xF0;
Delay_100ms();
Spi_Init_Advanced(MASTER_OSC_DIV16, DATA_SAMPLE_MIDDLE, CLK_IDLE_HIGH, LOW_2_HIGH);
PORTB=0x50;
Delay_100ms();
M_Create_New_File();
}
}
}
I need more memory.
Any advice we would welcome.
Thanks in advance!
Velimir