patelvivekv1993
Newbie level 6
- Joined
- Feb 21, 2014
- Messages
- 11
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 81
i am trying to interface dsPIC33FJ12MC201 with sdcard in proteus using mikro c library but i am not able to get the output . i have used same library for PIC18F4550 and it works but here there is some problem due to PPS select bits cauz the data input pin is not behaving as it should behave i am having a grey dot at that point.....i am attaching my code as well as the proteus file.
i have used the library feature and i am getting the PPS_mapping correctly but i think i ma having the problem with using the SPI module please help me here
i have used the library feature and i am getting the PPS_mapping correctly but i think i ma having the problem with using the SPI module please help me here
Code:
//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);
}
}