//Memory Card Chip Select Connection
sfr sbit Mmc_Chip_Select at RB7_bit;
sfr sbit Mmc_Chip_Select_Direction at TRISB7_bit;
unsigned int temp,temp1,temp2;
unsigned char filename[] = "vivek.txt";
unsigned char error;
double adc_value,voltage;
unsigned char tagline[] = " hello i am vivek using mikro c ";
void main()
{
AD1PCFGL = 0xffff;
temp=PPS_Mapping(0,_INPUT,_SDI1);
temp1=PPS_Mapping(1,_OUTPUT,_SDO1);
temp2=PPS_Mapping(4,_OUTPUT,_SCK1OUT);
TRISA.TRISA0 = 0;
TRISA.TRISA1 = 0;
TRISA.TRISA4 = 0;
if(temp==255)
{
LATA.LATA0 = 1;
}
if(temp1==255)
{
LATA.LATA1 = 1;
}
if(temp2==255)
{
LATA.LATA4 = 1;
}
TRISB.TRISB12 = 0;
LATB.LATB12 = 1;
SPI1_Init();
SPI1_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, _SPI_PRESCALE_SEC_1, _SPI_PRESCALE_PRI_64,_SPI_SS_DISABLE,
_SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_ACTIVE_2_IDLE);
error = MMC_Init();
while(error == 1)
{
LATB.LATB12 =1;
error = MMC_Init();
}
LATB.LATB12 = 0;
MMC_Fat_Init();
SPI1_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, _SPI_PRESCALE_SEC_1, _SPI_PRESCALE_PRI_4,_SPI_SS_DISABLE,
_SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_ACTIVE_2_IDLE);
Mmc_Fat_Assign(&filename,0x80);
while(1)
{
Mmc_Fat_Append();
Mmc_Fat_Write(tagline,sizeof(tagline));
Delay_ms(300);
}
}