TODOPIC

Microcontroladores PIC => Todo en microcontroladores PIC => Mensaje iniciado por: adbensi en 20 de Diciembre de 2006, 20:50:47

Título: Easy SD/MMC y PIC18F4550
Publicado por: adbensi en 20 de Diciembre de 2006, 20:50:47
Good day.

I have the MikroC version 5.0.0.3, and I am to try make one project with Mmc_Fat16_Test example, but it doen´t work. The funcion Mmc_Fat_Init(&PORTC,2) return false :(

What is wrong? Can to see my circuit bellow ?

I have connected these pins in MMC card - PIC

SD/MMC PIN - PIC18F4550
1 CS       - RC2/CCP1 pin 17 OUTPUT
2 SDI      - RC7/SDO  pin 26 OUTPUT
3 GND
4 3.3 Vcc
5 SCK      - RB1/SCL  pin 34 OUTPUT
6 GND
7 SDO      - RB0/SDI  pin 33 INPUT

    TRISA = 0b00100000; // SS must have TRISA<5> bit set, to GND.
    TRISB = 0b00000001; // SDI is automatically controlled by the SPI module.
      // SCK (Master mode) must have TRISB<1> bit cleared.
    TRISC = 0b00000000; // SDO must have TRISC<7> bit cleared
    TRISD = 0b00000000;
    TRISE = 0b00000000;   

Device Flags to PIC18F4550 20MHz HS_PLL:
PLL_div_5, CPU_div_osc1_PLL2, FOSC_HS_PLL_HS, FCMEM_OFF, IESO_OFF,
PWRT_OFF, BOR_OFF, VRGEN_OFF, WDT_OFF, MCLRE_EN, CCP2MX_OFF

I have conected the MMC card (try 8MB CE and 16MB Cannon) in PIC18F4550.

The MMC card works whith Standard Card Reader (it is formated in WinXP - format G: /FS:FAT /A:512).

My code of Mmc_Fat16_Test (see Mmc_Fat16_Test.zip to full version):

void main() {

    TRISA = 0b00100000; // SS must have TRISA<5> bit set, to GND.
    TRISB = 0b00000001; // SDI is automatically controlled by the SPI module.
         // SCK (Master mode) must have TRISB<1> bit cleared.
    TRISC = 0b00000000; // SDO must have TRISC<7> bit cleared
    TRISD = 0b00000000;
    TRISE = 0b00000000;

     //--- set down STATUS Led
     PORTA.F0 = 0;
     Delay_ms(100);
   
     //--- set up USART for the file read
     Usart_Init(9600);
     Delay_ms(100);
     //--- init the FAT library
     Spi_Init_Advanced(MASTER_OSC_DIV16, DATA_SAMPLE_MIDDLE, CLK_IDLE_LOW, LOW_2_HIGH);
     Delay_ms(250);
     if (Mmc_Fat_Init(&PORTC,2)) {

         //--- Test routines. Uncomment them one-by-one to test certain features
         M_Create_New_File();

           while(1){
             PORTA.F0 = !PORTA.F0;
             Delay_ms(1000);
            }

     }
     else {
       I_Write_Str(FAT_ERROR);
       while(1);
     }

}//~!

Thanks a lott,
Alexandre.
Título: Re: Easy SD/MMC y PIC18F4550
Publicado por: raus en 21 de Diciembre de 2006, 10:36:15
Hi!

I'm developing a similar project but, as I still haven't started with the code, the only thing I can do is to ask you about the schematics:

-Have you set the pull-up resistors specified by the SD specifications?
-Are you feeding the card with the proper 3V, rather than 5V? (if this is the problem you can either put a voltage regulator between +5V source and the card voltage input, or use one of the PICs that can be feeded with 3V)
-Are you using any kind of TTL buffer between the card and the pic? (in case your pic works at +5V)
-Have you formatted the card in FAT16 before inserting in the socket?

I know this questions are very basic, but if you don't respect them, maybe this is the cause of your problems. When I start coding, I'll post my results here.

Good luck!!
Título: Re: Easy SD/MMC y PIC18F4550
Publicado por: adbensi en 21 de Diciembre de 2006, 20:06:27
Hellow Raus, buenos dias,  :-/

 Estoy con alguns resistores en las patitas del MMC card para hacer la funcion Pull-up, espero estar correcto con my circuito. Por favor, mira el archivo anexo circuito.gif

 Yo va buscar regusladores y resistores mejores para hacer la division de tensão, estoy alimentando la tarjeta MMC con 3.1Vcc.

 No tieno TTL buffer in circuit, puesso hacer asy conforme la imagem anexa?

 E por fim, gracias por su ayuda, acredito que estoy usando sistema FAT (format g: /FS:FAT).
 En WinXP FAT16 no estas disponible, en outras bibliografias dizem que FAT és na verdade FAT16. Acredito que seja FAT = FAT16 porque las tarjetas são menores que 32MB, e no se puede formatar tarjetas < 32MB con FAT32. :)

uno grande abraço :D
Alexandre.
Título: Re: Easy SD/MMC y PIC18F4550
Publicado por: raus en 22 de Diciembre de 2006, 05:23:41
Ahora estoy en el trabajo y no puedo revisarlo con mas calma, pero en principio te diria que me resulta un poco raro que no haya en ese esquematico ninguna señal de tierra (GND), no?
Título: Re: Easy SD/MMC y PIC18F4550
Publicado por: adbensi en 22 de Diciembre de 2006, 08:41:12
Bom dia Rau!

 Sy, tieno GND (pin 12 y 31 del PIC) y Vcc (pin 11 y 32 del PIC). Me desculpa não ter-lo conectado na imagem. Estoy usando ploto-board, y la imagem en eagle és solo explicacion, me gusta anexar la imagem del ploto-board :) És muy primário :)

 Me ayda muito sy pueder revisarlo, tieno duda en algunas partes  :?

  SD/MMC PIN - PIC18F4550
  1 CS       - RC2/CCP1 pin 17 OUTPUT
  2 SDI      - RC7/SDO  pin 26 OUTPUT
  5 SCK     - RB1/SCL   pin 34 OUTPUT
  7 SDO     - RB0/SDI   pin 33 INPUT

  No entendo porque el datasheet informa que TRISA<5> debes ser ativado, tieno duda se RA5 en GND ou Vcc :(  (datasheet del 18F4550 pg 195)

  TRISA = 0b00100000; // SS must have TRISA<5> bit set, to GND.
  TRISB = 0b00000001; // SDI is automatically controlled by the SPI module.
                                   // SCK (Master mode) must have TRISB<1> bit cleared.
  TRISC = 0b00000000; // SDO must have TRISC<7> bit cleared
  TRISD = 0b00000000;
  TRISE = 0b00000000;

  Spi_Init_Advanced(MASTER_OSC_DIV16, DATA_SAMPLE_MIDDLE, CLK_IDLE_LOW, LOW_2_HIGH);
   
Gracias, :D
Alexandre.
Título: SD/MMC y PIC18F4550
Publicado por: bily en 11 de Agosto de 2007, 13:41:31
alguien tiene el codigo funcionando y probado estoy intentando funcionar pic16f877a y nada alguien que me ayude..