cancel
Showing results for 
Search instead for 
Did you mean: 

SDcard and LCD ?

antonius
Senior
Posted on April 14, 2014 at 01:23

Guys,

I have a question about SDcard and LCD initialization , Everytime I intialize LCD after SDcard, SDcard stopped working, is it because of port clock ? Thanks SDcard initialization :


void
SD_LowLevel_Init(
void
)

{

GPIO_InitTypeDef GPIO_InitStructure;


/*!< GPIOC and GPIOD Periph clock enable */

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | SD_DETECT_GPIO_CLK, ENABLE);


/*!< Configure PC.08, PC.09, PC.10, PC.11, PC.12 pin: D0, D1, D2, D3, CLK pin */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

//GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

GPIO_Init(GPIOC, &GPIO_InitStructure);


/*!< Configure PD.02 CMD line */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

GPIO_Init(GPIOD, &GPIO_InitStructure);


/*!< Configure SD_CD pin: SD Card detect pin */

GPIO_InitStructure.GPIO_Pin = SD_DETECT_PIN;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;

GPIO_Init(SD_DETECT_GPIO_PORT, &GPIO_InitStructure);


/*!< Enable the SDIO AHB Clock */

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_SDIO, ENABLE);


/*!< Enable the DMA2 Clock */

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE);

}

LCD initialization :


static
void
LCD_CtrlLinesConfig(
void
)

{

GPIO_InitTypeDef GPIO_InitStructure;


/* Enable FSMC, GPIOD, GPIOE and AFIO clocks */

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);


RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, ENABLE);


/* PE.07(D4), PE.08(D5), PE.09(D6), PE.10(D7), PE.11(D8), PE.12(D9),

PE.13(D10), PE.14(D11), PE.15(D12) */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 |

GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | 

GPIO_Pin_15;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

GPIO_Init(GPIOE, &GPIO_InitStructure);


/* PD.00(D2), PD.01(D3), PD.04(RD), PD.5(WR), PD.7(CS), PD.8(D13), PD.9(D14),

PD.10(D15), PD.11(RS) PD.14(D0) PD.15(D1) */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_7 | 

GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | 

GPIO_Pin_14 | GPIO_Pin_15;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

//GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

GPIO_Init(GPIOD, &GPIO_InitStructure);

}

#not-working
14 REPLIES 14
Posted on April 14, 2014 at 01:52

No, I think you have something else going on here.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
antonius
Senior
Posted on April 14, 2014 at 02:42

So it doesn't matter with GPIO clock speed ?

I'm wondering what the cause is ??

Posted on April 14, 2014 at 05:40

Are there some intrinsic conflicts between the FSMC and SDIO peripheral pins, or the pin used for the CD (Card Detect)? What does the manual suggest? Or the errata? Is there some direct conflict, or remapping required?

In what fashion is the SD Card interface not functioning after you enable the FSMC?

I'm not sure you've fully comprehended the purpose of the GPIO Speed parameter, in that it controls the slew rate of the pin (how aggressively it is driven high/low into a load). Having 20cm of wire hung about the board probably isn't terribly conducive to signal integrity.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
antonius
Senior
Posted on April 14, 2014 at 10:11

In what fashion is the SD Card interface not functioning after you enable the FSMC?

After I initialize LCD, SD card will not work,

but if I initialize SD card first then LCD, it will work, I want to combine both, retrieving data from SD card then display it to LCD...

Posted on April 14, 2014 at 15:14

Generally the point of debugging is to refine your understanding of what is failing and why, and then taking action to correct the problem.

You'll need to dig into your SDIO driver to better understand ''not working''
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
antonius
Senior
Posted on April 16, 2014 at 03:47

I'm thinking on LCD, it's sharing PORT D with SDIO


/* PD.00(D2), PD.01(D3), PD.04(RD), PD.5(WR), PD.7(CS), PD.8(D13), PD.9(D14),

PD.10(D15), PD.11(RS) PD.14(D0) PD.15(D1) */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_7 | 

GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | 

GPIO_Pin_14 | GPIO_Pin_15;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

//GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

GPIO_Init(GPIOD, &GPIO_InitStructure);

on SDIO :

1.
/*!< Configure PD.02 CMD line */
2.
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
3.
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
4.
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
5.
GPIO_Init(GPIOD, &GPIO_InitStructure);

does it matter by the time LCD function is running ? the status of PD2 is altering because of LCD init ?
Posted on April 16, 2014 at 04:33

I'm thinking on LCD, it's sharing PORT D with SDIO, on SDIO :, does it matter by the time LCD function is running ? the status of PD2 is altering because of LCD init ?

Yeah, you keep trying to make this connection, but other than relating to GPIO PORT D they all alter different pins. It seems pretty evident that this isn't the issue. What you have connected to the pins, and if they are the right pins, might be an issue, but this is only something you can review and test.

My secondary concern would be the defines you have for the CARD DETECT pin, which your code snippets fail to convey.

Once you have verified your pin connections, you need to look ELSEWHERE, because the issue is manifesting somewhere other than this. You need to identify the specific cause of failure for the SDIO, and then understand what might cause that.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on April 16, 2014 at 04:42

Per my earlier post, have you verified there isn't any SDIO + FSMC pin conflict in the Data Manual/Sheet, or any issue in the Errata. You need to do some basic due diligence here, as I don't plan to do it on your behalf.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
antonius
Senior
Posted on April 16, 2014 at 11:49

I checked them, there is no conflict...and card detect on PB14

#define SD_DETECT_PIN                    GPIO_Pin_14                 /* PB.14 */

#define SD_DETECT_GPIO_PORT              GPIOB                       /* GPIOB */

#define SD_DETECT_GPIO_CLK               RCC_APB2Periph_GPIOB

Is it possible for DMA conflict between SDIO and FSMC, since SDIO is using DMA channel4 ?...