Driving a LCD display with FMC on a STM32F429

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
Laurent
Posts: 35
Joined: Mon Mar 25, 2013 9:01 am

Driving a LCD display with FMC on a STM32F429

Post by Laurent »

Hi

I'm trying to drive a LCD display connected to the FMC peripheral, on the SFM32F429 DISCOVERY board. I'm having a hard time figuring out how to configure it with ChibiOS. Especially the timings in the BTR register: I really have no idea how to compute them (they are chosen randomly in my current code...).

I'd be grateful if anyone could explain the required steps to make this work, or point me to a tutorial/documentation.

My setup is as follows:
- the display is configured in mode '8080 MCU 8-bits Parallel type II'
- it is connected to NOR/PRSAM 1 of the STM32
- it uses chip select NE1 and register select A0
- datasheet of the LCD controller: http://www.displayfuture.com/Display/da ... HX8367.pdf
- I'm not using the built-in SDRAM and LCD display of the board

Here is what I have so far (using the community add-ons):

Code: Select all

#include <ch.h>
#include <hal.h>
#include <fsmc_sram.h>

#define LCD_ADDRESS (volatile uint16_t*)0x60000000;

const SRAMConfig sramConfig =
{
    .bcr = FSMC_BCR_MTYP_SRAM | FSMC_BCR_MWID_8 | FSMC_BCR_WREN | FSMC_BCR_MBKEN,
    .btr = FMC_BTR1_DATAST_2 | FMC_BTR1_ADDSET_1,
    .bwtr = 0,
};

void lcdStart()
{
    IOBus busD = {GPIOD, (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5) | (1 << 7) |
                         (1 << 8) | (1 << 9) | (1 << 10) | (1 << 14) | (1 << 15),
                         0};
    IOBus busE = {GPIOE, (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) |
                         (1 << 11) | (1 << 12) | (1 << 13) | (1 << 14) | (1 << 15),
                         0};
    IOBus busF = {GPIOF, (1 << 0),
                         0};
    IOBus busG = {GPIOG, (1 << 9),
                         0};
    palSetBusMode(&busD, PAL_MODE_ALTERNATE(12));
    palSetBusMode(&busE, PAL_MODE_ALTERNATE(12));
    palSetBusMode(&busF, PAL_MODE_ALTERNATE(12));
    palSetBusMode(&busG, PAL_MODE_ALTERNATE(12));

    fsmcSramInit();
    fsmcSramStart(&SRAMD1, &sramConfig);

    chThdSleepMilliseconds(100);
}

void main()
{
    halInit();
    chSysInit();

    lcdStart();

    // and then???
}


mcuconf_community.h:

Code: Select all

// FSMC driver system settings.
#define STM32_FSMC_USE_FSMC1                TRUE
#define STM32_FSMC_FSMC1_IRQ_PRIORITY       10

// FSMC SRAM (LCD) driver settings
#define STM32_USE_FSMC_SRAM         TRUE
#define STM32_SRAM_USE_FSMC_SRAM1   TRUE


Relevant parts of halconf_community.h:

Code: Select all

#if !defined(HAL_USE_COMMUNITY) || defined(__DOXYGEN__)
#define HAL_USE_COMMUNITY           TRUE
#endif

#if !defined(HAL_USE_FSMC) || defined(__DOXYGEN__)
#define HAL_USE_FSMC                TRUE
#endif


Thank you.
steved
Posts: 834
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 138 times

Re: Driving a LCD display with FMC on a STM32F429

Post by steved »

You could have a look at the uGfx project - they have lots of drivers and you may find other stuff useful.

My own experience (for a different controller) was that the time spent actually writing to the controller, and thus the timings for the FSMC bus, wasn't particularly significant in the overall scheme of things. So you can go for some fairly relaxed timings. (I can remember it takes a lot of careful reading of the ST UM and the controller data sheet to establish the fastest possible values).
Laurent
Posts: 35
Joined: Mon Mar 25, 2013 9:01 am

Re: Driving a LCD display with FMC on a STM32F429

Post by Laurent »

Thanks for your answer.

You could have a look at the uGfx project - they have lots of drivers and you may find other stuff useful.

I already did, and it helped me figure out how to start. But then I'm still stuck at finding the exact timings and other parameters needed for my specific display.

My own experience (for a different controller) was that the time spent actually writing to the controller, and thus the timings for the FSMC bus, wasn't particularly significant in the overall scheme of things. So you can go for some fairly relaxed timings.

Ok, I'll remember that. I already tried a bunch of timing combinations, but none of them worked. Well, the problem is that there are many parameters involved in the whole setup and there's no way to know what's wrong. So maybe at some point I got a working combination of timings, but also some other register badly configured...
Post Reply