mmc sd card

General discussion on Visual GLCD Software.
Post Reply
Author
Message
san4opa
Posts: 14
Joined: 28 Feb 2014 21:57

mmc sd card

#1 Post by san4opa » 01 Apr 2014 13:24

HI!
Please, help me :roll: . I am using smart glcd 240x128 with micro sd card(8gb), pic18f8722 and mikroC pro for pic. this is my code to Initialize SPI1 and storage device, but he can`t. I used standart code from Visual GLCD for SmartGLCD240x128_hw_rev_1.50 hardware pattern.

void Init_Ext_Mem() {
// Initialize SPI
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
Delay_ms(10);

// Initialize MMC
if (!Mmc_Fat_Init()) {
// Reinitialize SPI at higher speed
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);

// Open resource file for read
Mmc_Fat_Assign("%FILE_NAME", 0);
Mmc_Fat_Reset(&res_file_size);
}
}
But it don`t work. I can attach scheme in proteus and full code. Now I am using this code:

// MMC/SD Connections
sbit Mmc_Chip_Select at LATC0_bit;
sbit Mmc_Chip_Select_Direction at TRISC0_bit;
// end of MMC/SD

void main() {

Delay_ms(100);
// Initialize SPI
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW,_SPI_LOW_2_HIGH);

// Initialize MMC
if (Mmc_Fat_Init() == 0) {
// reinitialize spi at higher speed
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
//--- Test start
T6963C_write_text("11", 4, 4, T6963C_ROM_MODE_XOR);
}
else {
// Note: Mmc_Fat_Init tries to initialize a card more than once.
T6963C_write_text("00", 4, 4, T6963C_ROM_MODE_XOR);
}

Writes 00.

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: mmc sd card

#2 Post by petar.timotijevic » 02 Apr 2014 09:02

Hello,

Capacity of FAT16 disk is maximum 2GB.

Please see:
MikroC Pro - FAT32 Library
http://www.libstock.com/projects/view/108/fat32-library


Best regards,
Peter

san4opa
Posts: 14
Joined: 28 Feb 2014 21:57

Re: mmc sd card

#3 Post by san4opa » 06 Apr 2014 21:49

Thank you so much for support
i try this code, but error message is Unresolved extern `FAT32_Init`

// Initialize SPI
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
err = FAT32_Init();
// err = FAT32_format("dev0");
if (err < 0) //
{

T6963C_write_text("Fat32 inite", 4, 4, T6963C_ROM_MODE_XOR);
while(err < 0) // ...retry each second
{
err = FAT32_Init();
Delay_ms(1000);
}
}
///////////////////////////////////////
// if all went well, reinitialize
// SPI with greater speed
///////////////////////////////////////
// Initialize MMC
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
T6963C_write_text("00", 4, 4, T6963C_ROM_MODE_XOR);

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: mmc sd card

#4 Post by petar.timotijevic » 07 Apr 2014 07:24

Hello,

Library is included in Library Manager?


Best regards,
Peter

san4opa
Posts: 14
Joined: 28 Feb 2014 21:57

Re: mmc sd card

#5 Post by san4opa » 07 Apr 2014 11:48

Oh! yes, I did it, but another error is "not enough RAM `f32_sector` and indikate this line in __Lib_FAT32_Defs.c:

__RAW_SECTOR f32_sector;

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: mmc sd card

#6 Post by petar.timotijevic » 07 Apr 2014 13:55

Hello,

Please zip and attach your project files.


Best regards,
Peter

san4opa
Posts: 14
Joined: 28 Feb 2014 21:57

Re: mmc sd card

#7 Post by san4opa » 08 Apr 2014 08:41

Thank you!
Attachments
Project.rar
(387.85 KiB) Downloaded 194 times

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: mmc sd card

#8 Post by petar.timotijevic » 08 Apr 2014 14:26

Hi,

Please can you tell me what is "T6963C_MikroC_PRO.h" and do you have some version of source code with which I can recreate problematic situation?

Code: Select all

#include        "__T6963C.h"
#include "T6963C_MikroC_PRO.h"
#include "menu.h"
#include "__Lib_FAT32.h"
Best regards,
Peter

san4opa
Posts: 14
Joined: 28 Feb 2014 21:57

Re: mmc sd card

#9 Post by san4opa » 10 Apr 2014 12:29

Hi
I added T6963C_MikroC_PRO.h and make source code without errors. Thank you very much!
Attachments
Project.rar
(484.83 KiB) Downloaded 216 times

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: mmc sd card

#10 Post by petar.timotijevic » 10 Apr 2014 14:40

Hello,

With this code I get blank GLCD on my SmartGLCD 1.50 board.

Unfortunately with this code I can not recreate problematic situation.
san4opa wrote:but another error is "not enough RAM `f32_sector` and indikate this line in __Lib_FAT32_Defs.c: __RAW_SECTOR f32_sector;
You received this error during compiling process?


Best regards,
Peter

san4opa
Posts: 14
Joined: 28 Feb 2014 21:57

Re: mmc sd card

#11 Post by san4opa » 15 Apr 2014 09:27

Hello!
Error was disappeared, but he doesn`t initialize FAT32. indicates fat32 error.

Post Reply

Return to “Visual GLCD General”