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 TRUERelevant 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
#endifThank you.