cancel
Showing results for 
Search instead for 
Did you mean: 

3,2'' TFT LCD with FSMC

Posted on September 18, 2012 at 09:16

Hi everybody. I'm trying to display a bmp on 3,2'' TFT by using FSMC and stm32f4 graphic drivers. I've done writing some texts changing backcolour drawing pixels but when I want to draw or drive a bmp file with LCD_DrawMonoBMP or LCD_DrawColorBMP functions LCD shows me just white with some noisy white image. I added the screenshot. I need some help. Thanks a lot..0690X00000602lYQAQ.jpg

11 REPLIES 11
Posted on September 19, 2012 at 15:12

Will anybody help me??

frankmeyer9
Associate II
Posted on September 19, 2012 at 15:34

You might need to provide some more detailed information about your issue.

From the vague description, I guess it could be a scale/orientation problem, or an uninitialized GRAM. My suggestion is to erase the the screen and draw some primitives (lines, pixels) to check that. The next step would be some small high-contrast test images.

Posted on September 20, 2012 at 08:07

Thank you fm. I can draw primvites. But when I want a draw/send a bmp file to the LCD, program is branching to the HardFaultHandler and display shows just white pixels.

void G_LCD_On_Init (void)

{  

 GL_LCD_Init();

 GL_SetTextColor(0xFFFF);

 GL_SetBackColor(0x0000);

 GL_Clear(0x0000);

 GL_SetFont(GL_FONT_SMALL);

 }

I'm using LcdHal.c driver functions and I'm callin LCD_DrawColorBMP(''untitiled'', 239, 319, 240, 320); ,bmp file is in the same file with the main.c

 I try to write just ''untitiled.bmp'' but it's still branching HardFault_Handler but there's nothing on LCD.

You might need to provide some more detailed information about your issue.

From the vague description, I guess it could be a scale/orientation problem, or an uninitialized GRAM. My suggestion is to erase the the screen and draw some primitives (lines, pixels) to check that. The next step would be some small high-contrast test images.

frankmeyer9
Associate II
Posted on September 20, 2012 at 09:54

Well, looks like you are half-way there.

I don't have any hardware that uses FSMC to drive a TFT, so you can't expect me to reproduce the issue. And, I do not use the graphics library.

But if you end up in the HardFault handler, I suspect an access to a nonexisting GRAM address. I would either try to single-step through the offending function (possibly in assembly mode), or set a breakpoint in the HardFault handler and decode the associated registers for the reasons.

There are nice hardfault handler examples originally written by Joseph Yiu, which could be of help for you. You can even look inside this forum (if it got not lost during the last forum software updates...).

I would expect the reason to be some incorrect initialization or adaption of the library code to your hardware, like some colour depth mismatch. But as I said, I neither have the source code, nor the hardware or schematics - I can just guess.

Posted on September 21, 2012 at 08:53

Thank you fm. I'm using stm3241g_eval board it's most likely about GRAM. I'm new on microcontrollers so i'm a little half-way there but i'm trying on it. I found something about fault handler on arm.com and i think i have to find Joseph Yui's book

frankmeyer9
Associate II
Posted on September 21, 2012 at 10:16

The boards I have use GPIO with a bit-banging 8-bit interface, and not FSMC. The latter is definitively faster, but the boards came hardwired that way. And they have a TFT controller on the graphics module, that routes all accesses to GRAM (graphics RAM) via a register interface on that controller.

That does not seem to fit your setup.

Anyway, you probably need to rely on your debug tool to find the issue.

Either you single-step through this function, which might be required several times until you nail the offending machine instruction.

Or you try the post-mortem method, and decode the Hardfault handler output.

And you might need the board schematics and the datasheets/manuals of the LCD module and of the stm32f4xx to understand and fix it.

stm32forum
Associate II
Posted on September 21, 2012 at 22:17

If font and pixels are working i suggest that you try a other type of bmp file or find first out what bmp is supported by your code.

There are different type of bmp files, for example with or without rle encoding, etc.

http://www.fileformat.info/format/bmp/egff.htm

Posted on September 27, 2012 at 09:56

I've tried 16-bit bmp, 24-bit bmp and 16bit(565) coverted with ST's Resource Editor For Embeded GUI Library it is still same.. Now I'm trying to find reason of the HardFault_Handler (Joseph Yiu's Definitive Guide). I get an error then write the codes. I'm using Keill ;

__asm void HardFault_Handler(void)

{

  TST LR, #4

  ITE EQ

  MRSEQ R0, MSP

  MRSNE R0, PSP

  B hard_fault_handler_c

}

void hard_fault_handler_c (unsigned int * hardfault_args)

{

 unsigned int stacked_r0;

 unsigned int stacked_r1;

 unsigned int stacked_r2;

 unsigned int stacked_r3;

 unsigned int stacked_r12;

 unsigned int stacked_lr;

 unsigned int stacked_pc;

 unsigned int stacked_psr;

 stacked_r0 = ((unsigned long) hardfault_args[0]);

 stacked_r1 = ((unsigned long) hardfault_args[1]);

 stacked_r2 = ((unsigned long) hardfault_args[2]);

 stacked_r3 = ((unsigned long) hardfault_args[3]);

 stacked_r12 = ((unsigned long) hardfault_args[4]);

 stacked_lr = ((unsigned long) hardfault_args[5]);

 stacked_pc = ((unsigned long) hardfault_args[6]);

 stacked_psr = ((unsigned long) hardfault_args[7]);

 printf(''\n\n[Hard Fault Handler - All Numbers In Hex]\n'');

 printf(''R0 = %x\n'', stacked_r0);

 printf(''R1 = %x\n'', stacked_r1);

 printf(''R2 = %x\n'', stacked_r2);

 printf(''R3 = %x\n'', stacked_r3);

 printf(''R12 = %x\n'', stacked_r12);

 printf(''LR [R14] = %x subroutine call return address\n'', stacked_lr);

 printf(''PC [R15] = %x programm counter\n'', stacked_pc);

 printf(''PSR = %x\n'', stacked_psr);

 printf(''BFAR = %x\n'', (*((volatile unsigned long *)(0XE000ED38))));

 printf(''CFSR = %x\n'', (*((volatile unsigned long *)(0XE000ED28))));

 printf(''HFSR = %x\n'', (*((volatile unsigned long *)(0XE000ED2C))));

 printf(''DFSR = %x\n'', (*((volatile unsigned long *)(0XE000ED30))));

 printf(''AFSR = %x\n'', (*((volatile unsigned long *)(0XE000ED3C))));

 printf(''SCB_SHCSR = %x\n'', SCB->SHCSR);

 while(1)

 ;

} { ..\stm32f4xx_it.c(60): error: A1516E: Bad symbol 'hard_fault_handler_c', not defined or external } I defined hard_fault_handler_c externally at stm32f4xx_it.h file. I can see some registers in debug mode but I can't see last 6 registers(BFAR, CFSR, HFSR, DFSR, AFSR, SCB->SHCSR).

Posted on September 27, 2012 at 17:27

I put the assembler portion in startup_stm32f4xx.s

HardFault_Handler\
PROC
; EXPORT HardFault_Handler [WEAK]
EXPORT HardFault_Handler 
; Determine correct stack
TST lr, #4
ITE EQ
MRSEQ R0, MSP ; Read MSP (Main)
MRSNE R0, PSP ; Read PSP (Process)
EXTERN hard_fault_handler_c
B hard_fault_handler_c
B .
ENDP

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..