Hello, I have been trying to write a text file in an sd card with a pic33fj128gp802, im using the MikroC for dspic MMC library but it wont work
I'll paste the code in here for you to see, the code is ok until the part I try to write, i've tested the code by creating the txt but not writing to it and
it is OK, but as soon as I add the writing part, the pic does nothing at all, please tell me if you know whats going on.
void main() {
char Contenido[9];
Contenido[9] = "HOLA JUAN";
AD1PCFGL = 0XFFFF; //TODOS LOS PINES COMO DIGITALES
DCICON1 = 0X0701;
DCICON2 = 0X0C6F;
DCICON3 = 0X0000;
TRISA = 0X0000; // TODOS LOS PINES COMO SALIDA
TRISB = 0x00E2; //ASIGNA EL PIN RB7, RB6, RB5 Y RB1 COMO ENTRADA Y LOS DEMAS SALIDA
RSCON = 0X0005;
TSCON = 0X0000;
UNLOCK_IOLOCK();
RPOR0 = 0X000D; //ASIGNA CSOUT A RP0
RPINR20 = 0X0001; //ASIGNA SPI INPUT A RP1
RPOR1 = 0X0807; //ASIGNA SPI OUTPUT A RP2 Y SPI CLOCK OUTPUT A RP3
RPINR24 = 0X0507; //ASIGNA CSCK Y CSDI A RP5 Y RP7
RPINR25 = 0X0006; //ASIGNA COFS A RP6
LATA = 0X0;
LATB = 0X0;
SPI1_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, _SPI_PRESCALE_SEC_1, _SPI_PRESCALE_PRI_16,_SPI_SS_DISABLE,
_SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_ACTIVE_2_IDLE);
if (!Mmc_Fat_Init()) {
LATB.B8 = 1;
Mmc_Fat_Assign("JUAN.TXT", 0XA0);
Mmc_Fat_Rewrite();
Mmc_Fat_Write("HOLA JUAN", 10);
}
else {
LATB.B8 = 1;
delay_ms(1000);
LATB.B8 = 0;
}
}