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
antonius
Senior
Posted on April 16, 2014 at 11:51

void SD_LowLevel_DMA_RxConfig(uint32_t *BufferDST, uint32_t BufferSize)
{
DMA_InitTypeDef DMA_InitStructure;
DMA_ClearFlag(DMA2_FLAG_TC4 | DMA2_FLAG_TE4 | DMA2_FLAG_HT4 | DMA2_FLAG_GL4);
/*!< DMA2 Channel4 disable */
DMA_Cmd(DMA2_Channel4, DISABLE);
/*!< DMA2 Channel4 Config */
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)SDIO_FIFO_ADDRESS;
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)BufferDST;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
DMA_InitStructure.DMA_BufferSize = BufferSize / 4;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA2_Channel4, &DMA_InitStructure);
/*!< DMA2 Channel4 enable */
DMA_Cmd(DMA2_Channel4, ENABLE); 
}

antonius
Senior
Posted on April 16, 2014 at 12:27

0690X00000602t7QAA.jpg

static void LCD_FSMCConfig(void)
{
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef FSMC_NORSRAMTimingInitStructure;
/* FSMC¶�?ËÙ¶ÈÉèÖà */
FSMC_NORSRAMTimingInitStructure.FSMC_AddressSetupTime = 30; /* µØÖ·½¨�?¢Ê±¼ä */
FSMC_NORSRAMTimingInitStructure.FSMC_AddressHoldTime = 0; 
FSMC_NORSRAMTimingInitStructure.FSMC_DataSetupTime = 30; /* Êý¾�?½¨�?¢Ê±¼ä */
FSMC_NORSRAMTimingInitStructure.FSMC_BusTurnAroundDuration = 0x00;
FSMC_NORSRAMTimingInitStructure.FSMC_CLKDivision = 0x00;
FSMC_NORSRAMTimingInitStructure.FSMC_DataLatency = 0x00;
FSMC_NORSRAMTimingInitStructure.FSMC_AccessMode = FSMC_AccessMode_A; /* FSMC ·ÃÎÊģʽ */
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &FSMC_NORSRAMTimingInitStructure;
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); 
/* FSMC�?´ËÙ¶ÈÉèÖà */
FSMC_NORSRAMTimingInitStructure.FSMC_AddressSetupTime = 2; /* µØÖ·½¨�?¢Ê±¼ä */
FSMC_NORSRAMTimingInitStructure.FSMC_AddressHoldTime = 0; 
FSMC_NORSRAMTimingInitStructure.FSMC_DataSetupTime = 2; /* Êý¾�?½¨�?¢Ê±¼ä */
FSMC_NORSRAMTimingInitStructure.FSMC_BusTurnAroundDuration = 0x00;
FSMC_NORSRAMTimingInitStructure.FSMC_CLKDivision = 0x00;
FSMC_NORSRAMTimingInitStructure.FSMC_DataLatency = 0x00;
FSMC_NORSRAMTimingInitStructure.FSMC_AccessMode = FSMC_AccessMode_A; /* FSMC ·ÃÎÊģʽ */
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &FSMC_NORSRAMTimingInitStructure; 
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); 
/* Enable FSMC Bank1_SRAM Bank */
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE); 
}

Posted on April 16, 2014 at 15:25

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

 

I don't know, what do you think the conflict would be? Is there some documentation that suggests there is? Are you DMA'ing from the SDIO to the FSMC external memory. Debugging should have to be about random guessing.

Your FSMC configuration is broken, if your read/write parameters are actually different you need to create TWO descriptors, calling FSMC_Init() twice doesn't work that way.
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 17, 2014 at 00:42

any better suggestions for it ? thanks

antonius
Senior
Posted on April 17, 2014 at 01:09

For now, I fixed it by using only one configuration for read and write for FSMC, now I can initialize LCD before SDcard and it's working allright.....thanks