pic 18f2550 , micro sd and MikroC

Thread Starter

dxtr

Joined Oct 14, 2012
1
Hey everyone
i want to interface my micro sd with pic 18f2550 , i format it with FAT 16 and i used the code in the mmc help section
here is my code :
Rich (BB code):
// MMC module connections
sbit Mmc_Chip_Select           at LATC0_bit;  // for writing to output pin always use latch (PIC18 family)
sbit Mmc_Chip_Select_Direction at TRISC0_bit;
// eof MMC module connections

 int i;

void main() {
  ADCON1 |= 0x0F;                  // Configure AN pins as digital
  CMCON  |= 7;                     // Turn off comparators
  trisa = 0x00;

  // Initialize SPI1 module
  SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
    while (1)
    {
   i = Mmc_Fat_Init();
 switch (i)
   {
      case 0 : porta = 0b00000001; break;
      case 1 : porta = 0b00000010; break;
      case 255 : porta = 0b00000011; break;
      default: porta = 0xff; break;
      }
      delay_ms(50);
     }
}}
i always get 255
i even tried with MMC_INIT() with no result
can u please guide me to the problem ?
 
Top