Good day.
I have the MikroC version 5.0.0.3, and I am to try make one project with Mmc_Fat16_Test example, but it doen´t work. The funcion Mmc_Fat_Init(&PORTC,2) return false
What is wrong? Can to see my circuit bellow ?
I have connected these pins in MMC card - PIC
SD/MMC PIN - PIC18F4550
1 CS - RC2/CCP1 pin 17 OUTPUT
2 SDI - RC7/SDO pin 26 OUTPUT
3 GND
4 3.3 Vcc
5 SCK - RB1/SCL pin 34 OUTPUT
6 GND
7 SDO - RB0/SDI pin 33 INPUT
TRISA = 0b00100000; // SS must have TRISA<5> bit set, to GND.
TRISB = 0b00000001; // SDI is automatically controlled by the SPI module.
// SCK (Master mode) must have TRISB<1> bit cleared.
TRISC = 0b00000000; // SDO must have TRISC<7> bit cleared
TRISD = 0b00000000;
TRISE = 0b00000000;
Device Flags to PIC18F4550 20MHz HS_PLL:
PLL_div_5, CPU_div_osc1_PLL2, FOSC_HS_PLL_HS, FCMEM_OFF, IESO_OFF,
PWRT_OFF, BOR_OFF, VRGEN_OFF, WDT_OFF, MCLRE_EN, CCP2MX_OFF
I have conected the MMC card (try 8MB CE and 16MB Cannon) in PIC18F4550.
The MMC card works whith Standard Card Reader (it is formated in WinXP - format G: /FS:FAT /A:512).
My code of Mmc_Fat16_Test (see Mmc_Fat16_Test.zip to full version):
void main() {
TRISA = 0b00100000; // SS must have TRISA<5> bit set, to GND.
TRISB = 0b00000001; // SDI is automatically controlled by the SPI module.
// SCK (Master mode) must have TRISB<1> bit cleared.
TRISC = 0b00000000; // SDO must have TRISC<7> bit cleared
TRISD = 0b00000000;
TRISE = 0b00000000;
//--- set down STATUS Led
PORTA.F0 = 0;
Delay_ms(100);
//--- set up USART for the file read
Usart_Init(9600);
Delay_ms(100);
//--- init the FAT library
Spi_Init_Advanced(MASTER_OSC_DIV16, DATA_SAMPLE_MIDDLE, CLK_IDLE_LOW, LOW_2_HIGH);
Delay_ms(250);
if (Mmc_Fat_Init(&PORTC,2)) {
//--- Test routines. Uncomment them one-by-one to test certain features
M_Create_New_File();
while(1){
PORTA.F0 = !PORTA.F0;
Delay_ms(1000);
}
}
else {
I_Write_Str(FAT_ERROR);
while(1);
}
}//~!
Thanks a lott,
Alexandre.