cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F7 Discovery SDRAM and TFT-LCD

Thomas Gonnot
Associate II
Posted on July 10, 2015 at 18:03

Hello,

I received my STM32F746G-DISCO board 2 days ago, and I am trying to get the TFT-LCD module work, but I am having difficulties with the configuration of the FMC.I am struggling with the timing configuration for the SDRAM. I think I got it right for the most part, but I still can't access the memory. My FMC initialization function is the following:

void
MX_FMC_Init(
void
)
{
FMC_SDRAM_TimingTypeDef SdramTiming;
/** Perform the SDRAM1 memory initialization sequence
*/
hsdram1.Instance = FMC_SDRAM_DEVICE;
/* hsdram1.Init */
hsdram1.Init.SDBank = FMC_SDRAM_BANK1;
hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8;
hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_11;
hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16;
hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;
hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_2;
hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE;
hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2;
hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE;
hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0;
/* SdramTiming */
SdramTiming.LoadToActiveDelay = 2;
SdramTiming.ExitSelfRefreshDelay = 7;
SdramTiming.SelfRefreshTime = 7;
SdramTiming.RowCycleDelay = 16; 
//???
SdramTiming.WriteRecoveryTime = 1;
SdramTiming.RPDelay = 12;
SdramTiming.RCDDelay = 2;
HAL_SDRAM_Init(&hsdram1, &SdramTiming);
}

Ultimatly I would like to use also the TFT-LCD, and I think I found the model there: http://www.rocktech.com.hk/Tpadb.aspx However, I couldn't find the exact datasheet for the capacitive touch screen controller. I could only find datasheets for controllers from the same familly. Does anyone has the correct one? Regards #sdram #fmc #stm32f7 #emwin #discovery #stm32f7-lcd
7 REPLIES 7
Posted on July 10, 2015 at 21:51

Why wouldn't you review stm32746g_discovery_sdram.c ?

You might have to goose the timings slightly if running >100 MHz, but not by much.

/**
* @brief Initializes the SDRAM device.
* @retval SDRAM status
*/
uint8_t BSP_SDRAM_Init(void)
{ 
static uint8_t sdramstatus = SDRAM_ERROR;
/* SDRAM device configuration */
sdramHandle.Instance = FMC_SDRAM_DEVICE;
/* Timing configuration for 100Mhz as SD clock frequency (System clock is up to 200Mhz) */
Timing.LoadToActiveDelay = 2;
Timing.ExitSelfRefreshDelay = 7;
Timing.SelfRefreshTime = 4;
Timing.RowCycleDelay = 7;
Timing.WriteRecoveryTime = 2;
Timing.RPDelay = 2;
Timing.RCDDelay = 2;
sdramHandle.Init.SDBank = FMC_SDRAM_BANK1;
sdramHandle.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8;
sdramHandle.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12;
sdramHandle.Init.MemoryDataWidth = SDRAM_MEMORY_WIDTH;
sdramHandle.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;
sdramHandle.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_2;
sdramHandle.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE;
sdramHandle.Init.SDClockPeriod = SDCLOCK_PERIOD;
sdramHandle.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE;
sdramHandle.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0;
/* SDRAM controller initialization */
BSP_SDRAM_MspInit(&sdramHandle, NULL); /* __weak function can be rewritten by the application */
if(HAL_SDRAM_Init(&sdramHandle, &Timing) != HAL_OK)
{
sdramstatus = SDRAM_ERROR;
}
else
{
sdramstatus = SDRAM_OK;
}
/* SDRAM initialization sequence */
BSP_SDRAM_Initialization_sequence(REFRESH_COUNT);
return sdramstatus;
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Thomas Gonnot
Associate II
Posted on July 10, 2015 at 22:10

Thanks for the tip, I actually didn't see this file -_-'

However, it seems that (in debug mode, with uVision) it manages to write in few memory locations before failing. My guess is that the FIFO might be filling up too fast? Should I check if the device is busy before writing?

I will try that.

Thanks

Posted on July 10, 2015 at 22:30

I guess I'd try rebuilding, or reviewing the demo, and confirm if the SDRAM works from that.

STM32Cube_FW_F7_V1.1.0\Projects\STM32746G-Discovery\Demonstration\MDK-ARM

Simpler use case

STM32Cube_FW_F7_V1.1.0\Projects\STM32746G-Discovery\Examples\BSP\Src\main.c

Or review the mechanics of SystemInit_ExtMemCtl()

STM32Cube_FW_F7_V1.1.0\Projects\STM32746G-Discovery\Examples\DMA2D\DMA2D_MemToMemWithBlending\Src\system_stm32f7xx.c

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 10, 2015 at 22:34

STM32Cube_FW_F7_V1.1.0\Projects\STM32746G-Discovery\Examples\FMC\FMC_SDRAM\Src\main.c

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Thomas Gonnot
Associate II
Posted on July 10, 2015 at 23:01

Ok, so I basically copies the function BSP_SDRAM_Initialization_Sequence(&hsdram, &command); and that did the trick.

There was way more things to configure!

I will try to use the TFT-LCD now, but with the original program available it shouldn't be too hard. I couldn't see it at the beginning because I had the version 1.0.0 instead of 1.1.0!

Thanks

vijay
Associate
Posted on April 04, 2016 at 14:50

Hi 

 I am trying to make a Qwerty Touch keypad in STM32F746-Disco.  From the Segger sample i downloaded the notepad.c file 

https://www.segger.com/cms/admin/uploads/userfiles/file/emWin/samples/src/SKINNING_Notepad.zip

i included notepad.c file in STM32Cube_FW_F7_V1.1.0 Demonstration and fire the event to open notepad GUI from gardencontrol.c button click.

I changed some lines of Maintask() as below . as per the code Notepad will display and go off after 500ms. 

The PROBLEM  after the Notepad GUI goes off , again i click the button to show it. Like this after 14 times my display

gets hangup. How to tackle it?

void Qwertypad()

{

 WM_HWIN hKeypad;

 WM_HWIN hFrame;

 WM_HWIN hMulti;

 WM_HWIN hAnim;

 hMulti = 0;

 //

 // Initialize emWin

 //

 //WM_SetCreateFlags(WM_CF_MEMDEV);

 //WM_SetCallback(WM_HBKWIN, _cbBk);

 //GUI_CURSOR_Show();

   //

   // Set widget default settings for keypad

   //

   BUTTON_SetDefaultSkin(_DrawSkinFlex_BUTTON);

   //

   // Create keypad

   //

   hKeypad = WM_CreateWindowAsChild(0, 120, 320, 120, WM_HBKWIN, WM_CF_SHOW | WM_CF_STAYONTOP, _cbKeyPad, 0);

   //hKeypad=WM_CreateWindow(0,120,320, 140, WM_CF_SHOW, _cbKeyPad, 0);

   hFrame = 0;

   if(hFrame==0)

   {

   //BUTTON_SetDefaultSkin(BUTTON_SKIN_FLEX);

        BUTTON_SetDefaultSkin(_BUTTON_DrawSkinFlex);

        FRAMEWIN_SetDefaultSkin(FRAMEWIN_SKIN_FLEX);

        FRAMEWIN_SetDefaultTextAlign(GUI_TA_HCENTER);

        //

        // Create frame window

        //

        hFrame = FRAMEWIN_CreateEx(0, 0, 320, 240, WM_HBKWIN, WM_CF_SHOW, 0, 0, ''Notepad'', 0);

        FRAMEWIN_SetTextColor(hFrame, GUI_BLACK);

        FRAMEWIN_SetFont(hFrame, &GUI_Font20_AA4);

        FRAMEWIN_SetClientColor(hFrame, GUI_WHITE);

        FRAMEWIN_AddCloseButton(hFrame, FRAMEWIN_BUTTON_RIGHT, 0);

        //

        // Create multi edit widget

        //

        hMulti = MULTIEDIT_CreateEx(0, 0, 0, 0, WM_GetClientWindow(hFrame), WM_CF_SHOW, 0, GUI_ID_MULTIEDIT0, 100, NULL);

        MULTIEDIT_SetWrapWord(hMulti);

        MULTIEDIT_SetFont(hMulti, GUI_FONT_16B_ASCII);

        WM_SetFocus(hMulti);

   }

//    // Use animation functions to make editor and keypad visible

//       //

//       GUI_MEMDEV_ShiftInWindow(hFrame, 500, GUI_MEMDEV_EDGE_LEFT);

//       GUI_MEMDEV_ShiftInWindow(hKeypad, 500, GUI_MEMDEV_EDGE_BOTTOM);

      GUI_Delay(500);

//       //

       GUI_MEMDEV_ShiftOutWindow(hKeypad, 500, GUI_MEMDEV_EDGE_BOTTOM);

       if (WM_IsWindow(hFrame)) {

         GUI_MEMDEV_ShiftOutWindow(hFrame, 500, GUI_MEMDEV_EDGE_RIGHT);

         MULTIEDIT_SetText(hMulti, '''');

       } else {

         hFrame = 0;

       }

       //GUI_Delay(50);

}

[i posted here because i couldnt create new discussion]