Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

interfacing a dspic with an sd card

Status
Not open for further replies.

rikrdos6

Newbie level 4
Joined
Jul 3, 2011
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,329
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;
}
}
 

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;
}
}


first you read the complete spi manual and set the register value as per your requirement and you first test on simulator then try to implement on hardware..........
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top