Page 7 of 14

Re: GLCD and Touchpad Library

Posted: Wed Jul 04, 2012 5:56 pm
by miguelmoreto
Hello Anubirux and Abhishek,

The RS signal is connected at A20, so the LCD addresses are:

Code: Select all

#define LCD_REG              (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */
#define LCD_RAM              (*((volatile uint16_t *) 0x60200000)) /* RS = 1 (using address line A20) */


I'am measuring signals with an oscilloscope. Now, 16bit data lines are 0x898A. I don't know why, but some hours ago, all data lines was at level 1. NOE=0, NWE=1, NE1(CS)=0 (seems to be floating) and A20=0 (also seems to float).

I don't now check the FSMC registers during debug, I'am using eclipse with CDT and STlink GDB server. I installed eclipse plugin EmbSys Registers. The plugin have some definitions of stm32F4 registers but it does not seem to work (or I didn't configure it correctly).

@abhishek

Yes, I used ST lib, I checked the code and ST lib macros. It seems the same configuration. But I still need to calculate the timing configs. Anyway, even if MCU is throwing in data so fast the LCD will not respond, but I should see something in oscope, am I right? with non chibios code, a can clearly see the signals changing in my scope.


Best regards,

Miguel

Re: GLCD and Touchpad Library

Posted: Wed Jul 04, 2012 6:33 pm
by Anubirux
Solution for not working plugin.
http://sourceforge.net/p/embsysregview/discussion/964554/thread/42a46ec0?limit=50&page=0#b2e3

EDIIT:
Aha, if your'e using STM32F4 you have different GPIO config it might be problem. They all should be PushPull and correct altarnate function number. I don't know if current driver supports STM32F4 (GUI, cuz ChibiOS itself yes)

Re: GLCD and Touchpad Library

Posted: Wed Jul 04, 2012 8:33 pm
by miguelmoreto
Hello Anubirux,

thank you for the link! Now I can see the FSMC register.

The SRAM/NOR-Flash chip-select control registers 1 has the value 0x00001011, which is ok (In my oppinion): bank 1 enable, 16bit data bus, write enable, extended mode disabled, asynchronous write, no wait signal, NWAIT signal disable, burst disable, NOR flash disabled, memory type SRAM, Address data not multiplexed.

The GPIO config was done using pal driver from ChibiOS (output push-pull, alternate function 12 and high-speed mode), you can see at one of my previous post where I paste the code.

Like Abhishek stated, maybe something related with initialization. The code

Code: Select all

rccEnableAHB3(RCC_AHB3ENR_FSMCEN, 0);
is ok to initialize FSMC clock?

Best regards,

Miguel

Re: GLCD and Touchpad Library

Posted: Wed Jul 04, 2012 9:01 pm
by Anubirux
If you would have switched down FSMC and had tried write something through it then you would had Hard Fault, so with FSMC config its ok. Try reduce timings to highest possible values, check if GPIO registers are correct. Everything looks fine so without seeing all code I cant help you more. Maybe you should try also compare register values from working configuration, without chibi and with it.

Anubirux

Re: GLCD and Touchpad Library

Posted: Thu Jul 05, 2012 3:23 am
by miguelmoreto
Hi,

I checked GPIO registers and FSMC registers and found something!

I was using

Code: Select all

palSetGroupMode(GPIOE, 0xFF90, 0, PAL_MODE_ALTERNATE(12) | PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
to configure GPIOE and a similar line to GPIOD. I verified that after the execution of these lines, the MODER register contained "11" for every selected pin. This means analog input mode.

After changing the lines by

Code: Select all

palSetGroupMode(GPIOE, 0xFF90, 0, PAL_MODE_ALTERNATE(12) | PAL_STM32_OSPEED_HIGHEST);
the MODER register is correctly configured (also the OSPEEDR). When I use PAL_MODE_OUTPUT_PUSHPULL the MODER isn't correctly configured, is this some sort of pal driver bug?

Alternate function registers are OK and output push-pull is enable by default.

This way I can tell you that the LCD screen is red now, as expected! lcdClear is the only function I tested so far.

After reset, I noticed that lcdClear have to be executed several times in order to clear the screen (half screen red and half noise). Probably some timming issue. Now is fine tunning. At least now I can see some light at the end of the tunnel!

I would like to thank you for helping me!

Best regards,

Miguel

Re: GLCD and Touchpad Library

Posted: Thu Jul 05, 2012 8:04 pm
by miguelmoreto
Hello all,

thanks to Abhishek, now I can measure the frame per second rate of LCD connected in a STM32F4 discovery using FSMC.

This is the code for measuring:
Outside of main loop:

Code: Select all

 
 volatile halrtcnt_t before, fps;
 palSetPadMode(GPIOC, 7, PAL_MODE_OUTPUT_PUSHPULL);

Inside main loop:

Code: Select all

    // FPS measuring by software:
    before=halGetCounterValue();
    lcdClear(Red);
    before = halGetCounterValue() - before;

    fps = 168000000/before;

    // FPS measuring by a scope connected in GPIOC, pin 7:
    palSetPad(GPIOC, 7);
    lcdClear(Red);
    palClearPad(GPIOC, 7);


By setting FSMC BTR1 register bitfields DATAST=6 and ADDSET=0:

Code: Select all

FSMC_Bank1->BTCR[FSMC_Bank+1] = FSMC_BTR1_ACCMOD_0 | 0x00000600;

I can measure a FPS of 263Hz using the scope (257 by software), this means that the lcdClear function takes approximately 3,8ms to draw all the 320x240 pixels.

I don't know if this timming configuration is safe, maybe I'm pushing too hard the LCD controller and the code might not work in another device. I cannot check FSMC signals directly with my scope, it is a 100MHz, and the showed signals are distorted. It is necessary a digital signal analyser, but I don't have access to one.

By reading application note AN2970 (LCD interface with FSMC) from ST I calculated some values of DATAST and ADDSET, but I couldn't understand why the LCD is working with the above values as they are very different from the calculated ones. Also, I realized that ADDSET=0 or 1 does not make much difference in FPS. But I thought it would make huge difference. This is to conclude that I not fully understand FSMC timmings!

Best regards,

Miguel

Re: GLCD and Touchpad Library

Posted: Tue Jul 10, 2012 12:22 am
by Tectu
benwilliam wrote:hi@all
I'm a beginner with chibiOS and ARM
but I wrote once a simple graphic lib for an Atmega8 and a LED Matrix
it looks very similar to that one :)

but I have some more geometrical function like:
- ellipse (filled/unfilled)
- rotated ellipse (filled/unfilled)
- rotated recangle (filled/unfilled)
- shift the whole screen to any direction

is there any need for them?

i could try to port them to this lib

but I can only simulate it on a PC because of lack of such embedded Hardware


Thank you very much for your sharing. I could add lcdDrawEllipse() now. The rotated rectangle functions didn't work directly. I guess there isn't a big issue.
I'd be happy if you could make the Rect and Ellipse functions both taking an argument uint8_t filled where you can pass the enum frame or filled like lcdDrawRect(), lcdDrawCircle() etc.

P.S. How exactly do you simulate that stuff on your PC?


~ Tectu

Re: GLCD and Touchpad Library

Posted: Tue Jul 17, 2012 4:42 pm
by Abhishek
Hello all,

I've some good news [personal] to announce here.

I'm now a fresher [first year student] at the Indian Institute of Technology, Kharagpur (website: http://www.iitkgp.ac.in). I'll be pursuing a dual degree (Bachelors+Masters) in Electrical Engineering from here.

I hope this will further strengthen my association with circuits, embedded systems, and ChibiOS :) , and I'll be better abled to give back to the community.

Best Regards
Abhishek

Re: GLCD and Touchpad Library

Posted: Tue Jul 17, 2012 4:58 pm
by Giovanni
Congratulations :)

Re: GLCD and Touchpad Library

Posted: Tue Jul 17, 2012 6:15 pm
by Abhishek
Thank you very much Sir!