cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407 mbed/LCD Problem

George Beckstein
Associate
Posted on June 17, 2018 at 00:55

Hi all,

I'm fairly new to STM32 MCU's, but I've become fairly familiar with ARM while developing for the nRF528

I'm using mbed as my RTOS platform and my application requires an LCD screen.

I'm currently trying to talk to it with the FSMC peripheral as outlined in AN27 I understand how it works, but I'm having trouble getting everything set up properly... I'm not sure if mbed is possibly messing up the configuration but I don't think that should be an issue.

I am developing on the STM32F407G-DISC1 board and using an 8-bit I8080 parallel interface to talk to my display.

My main function looks like this:

 #include 'i8080_8bit_api.h'
#include 'stm32f4xx_hal_sram.h'
#include 'mbed_debug.h'
#include 'mbed_wait_api.h'
#include 'drivers/DigitalOut.h'
i8080_8bit_t bus;

mbed::DigitalOut led(LED1); 
int main(void) 
{
 i8080_8bit_init(&bus); 
 uint32_t* lcd_ptr; lcd_ptr = (uint32_t*)((uint32_t)0x64000000); 
 uint8_t i = 0xF3; 
 *lcd_ptr = i; 
 while(true)
 { 
 //SRAM_BANK_ADDR(0) = i; 
 //HAL_SRAM_Write_8b(&bus.sram_handle, (uint32_t*) 0x64000000, &i, 1); 
 //*((__IO uint8_t*)(0x64010000)) = i++;
 led = !led; 
 wait_ms(500);
 }
}

And the GPIO/FSMC initialization code looks like this:

void HAL_SRAM_MspInit(SRAM_HandleTypeDef* hsram)

{ GPIO_InitTypeDef GPIO_InitStructure;

/* Enable FSMC clock */

__HAL_RCC_FSMC_CLK_ENABLE();

/* Enable GPIOs clock */

__HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOE_CLK_ENABLE();

/*-- GPIO Configuration ------------------------------------------------------*/

/* SRAM Data lines, NOE (/RD) and NWE (/WR) configuration */

// 8-bit interface (PORT D)

GPIO_InitStructure.Pin = GPIO_PIN_14 // D0 | GPIO_PIN_15 // D1 | GPIO_PIN_0 // D2 | GPIO_PIN_1 // D3 | GPIO_PIN_7 // ~CS | GPIO_PIN_11 // ~RS | GPIO_PIN_4 // ~RD | GPIO_PIN_5; // ~WR GPIO_InitStructure.Mode = GPIO_MODE_AF_PP; GPIO_InitStructure.Pull = GPIO_NOPULL; GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStructure.Alternate = GPIO_AF12_FSMC;

HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);

// 8-bit interface (PORT E)

GPIO_InitStructure.Pin = GPIO_PIN_7 // D4 | GPIO_PIN_8 // D5 | GPIO_PIN_9 // D6 | GPIO_PIN_10; // D7 HAL_GPIO_Init(GPIOE, &GPIO_InitStructure);

/* RESET */

GPIO_InitStructure.Pin = GPIO_PIN_12; GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStructure.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12, GPIO_PIN_SET); }

void i8080_8bit_init(i8080_8bit_t *obj)

{ /** Configure the SRAM device */ obj->sram_handle.Instance = FSMC_NORSRAM_DEVICE; obj->sram_handle.Extended = FSMC_NORSRAM_EXTENDED_DEVICE;

obj->timing.AddressSetupTime = 3;

obj->timing.AddressHoldTime = 2; obj->timing.DataSetupTime = 3; obj->timing.BusTurnAroundDuration = 0; obj->timing.CLKDivision = 0; obj->timing.DataLatency = 0; obj->timing.AccessMode = FSMC_ACCESS_MODE_B;

obj->sram_handle.Init.NSBank = FSMC_NORSRAM_BANK1;

obj->sram_handle.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_DISABLE; obj->sram_handle.Init.MemoryType = FSMC_MEMORY_TYPE_SRAM; obj->sram_handle.Init.MemoryDataWidth = FSMC_NORSRAM_MEM_BUS_WIDTH_8; obj->sram_handle.Init.BurstAccessMode = FSMC_BURST_ACCESS_MODE_DISABLE; obj->sram_handle.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW; obj->sram_handle.Init.WaitSignalActive = FSMC_WAIT_TIMING_BEFORE_WS; obj->sram_handle.Init.WaitSignal = FSMC_WAIT_SIGNAL_DISABLE; obj->sram_handle.Init.ExtendedMode = FSMC_EXTENDED_MODE_DISABLE; obj->sram_handle.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE; obj->sram_handle.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE;

// Initialize the 'SRAM' FSMC interface

MBED_ASSERT(HAL_SRAM_Init(&obj->sram_handle, &obj->timing, &obj->timing) == HAL_OK); }

For some reason, I don't see any output on my oscilloscope...

In fact, as soon as I try to write to the SRAM memory location my program locks up. On-board LED1 should blink every second or so but it doesn't. If I comment out the write to SRAM then the LED blinks.

Any thoughts on what else I need to do?

Thanks!

#stm32f407 #fsmc #lcd
0 REPLIES 0