Page 6 of 14
Re: GLCD and Touchpad Library
Posted: Fri Jun 29, 2012 1:32 am
by Abhishek
Hi miguel,
I'm extremely happy to see the LCD Running over FSMC. [ However, I suppose now you wouldn't be able to use the audio features because of pin clashes between the CS43L22 reset pin and the FSMC pins. Exactly the reason why I went into split GPIO ]
You can also have a look at my self-designed F4 board with LCD link:
http://imageshack.us/photo/my-images/84 ... 768qf.jpg/ and also my project 'STM32 GUI and WavePlayer Demo' in the user projects section, code is available @
https://github.com/abhishek-kakkar/STM32F4PlayerActually, the Set_CS is a macro which does:
Code: Select all
#define SET_CS(a) (TP_PORT->BSRR = 1 << (TP_CS + (a ? 0 : 16)))
Unfortunately, the BSRR on the F4 platform is implemented as a 'union', it isn't a register!
So try replacing TP_PORT->BSRR with TP_PORT->BSRR.W . Your code should compile now.
If you face any further problems, feel free to ask questions on this forum. We all here would be happy to help!
Abhishek
[P.S. Miguel, could you please share your LCD FSMC Code?]
Re: GLCD and Touchpad Library
Posted: Fri Jun 29, 2012 9:10 am
by Badger
miguelmoreto wrote:After this tests I started to configure the FSMC, I wrote the configuration code but couldn't compile it. The first compilation error was about a non defined type chnflags_t returned by getflags funcion in console.c. I changed that by ioflags_t that are used by other getflags function in ChibiOS (like in serial.c). I searched all ChibiOS source code and could not find where chnflags_t is defined. Well, after that this compilation code is gone.
Are you using the latest (development) version of chibios from svn? there have been some changes to the iostreams recently, so it probably wont work without those.
I plan to get FSMC to work on stm32F4 this weekend, so I'll post my results.
Re: GLCD and Touchpad Library
Posted: Fri Jun 29, 2012 10:01 am
by Tectu
I replaced the touchpad macros with ChibiOS pal Macros. We won't have this problem anymore. I also added TP_CS_PORT.
Feel free to ask anything here, Miguel. You might also open a new thread in this subforum, if you have any bigger issues.
~ Tectu
Re: GLCD and Touchpad Library
Posted: Mon Jul 02, 2012 3:30 pm
by benwilliam
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
Re: GLCD and Touchpad Library
Posted: Mon Jul 02, 2012 3:37 pm
by Abhishek
It'd be more than welcome

. Do share with us. If need comes, we'll test it on our HW.
Abhishek
Re: GLCD and Touchpad Library
Posted: Wed Jul 04, 2012 3:33 pm
by miguelmoreto
Hello,
I'm trying to drive the SSD1289 LCD with FSMC. This is my code at lld_lcdInit in ssd1289_lld.c
Code: Select all
#ifdef LCD_USE_FSMC
/* FSMC setup. For STM32F4 Adapter board */
rccEnableAHB3(RCC_AHB3ENR_FSMCEN, 0);
int FSMC_Bank = 0;
/* timing structure */
/* from datasheet:
address setup: 2 HCLK periods
address hold: 0ns
Data setup: 2 HCLK periods
Data hold: 5ns
Data access: 250ns
output hold: 100ns
*/
FSMC_Bank1->BTCR[FSMC_Bank+1] = FSMC_BTR1_ADDSET_1 | FSMC_BTR1_DATAST_1;
/* Bank1 NOR/SRAM control register configuration
* Write operation enable, 16bit Data Width, Bank 0 enabled. */
FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN;
/* FSMC control lines config GPIOD: 1100011110110011 = 0xC7B3
* PD0: D2
* PD1: D3
* PD4: NOW -> LCD RD
* PD5: NWE -> WR
* PD7: NE1 -> CS
* PD8: D13
* PD9: D14
* PD10: D15
* PD14: D0
* PD15: D1 */
palSetGroupMode(GPIOD, 0xC7B3, 0, PAL_MODE_ALTERNATE(12) | PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
/* FSMC control lines config GPIOE: 1111111110010000 = OxFF90
* PE4: A20 -> RS
* PE7: D4
* PE8: D5
* PE9: D6
* PE10: D7
* PE11: D8
* PE12: D9
* PE13: D10
* PE14: D11
* PE15: D12*/
palSetGroupMode(GPIOE, 0xFF90, 0, PAL_MODE_ALTERNATE(12) | PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
#endif
I don't know the best place to put this code in, but in order to make a test a placed it in lcd_init function. Os course, LCD_USE_FSMC is defined.
I would like to now if I'm missing something in configuring FSMC because nothing is happening in FSMC pins.
I'm running the STM32F4 discovery demo from ChibiOS with AD and PWM (I commented out SPI stuff from demo). ChibiOS is working, the leds are flashing according to the AD measuring. I changed the demo code in order to not configure Discovery LED5 and LED6 that are used by FSMC.
Using another firmware (without chibiOS) my setup works with FSMC. I compared the FSMC config from that firwmare with this config using ChibiOS and it seems ok.
Best regards,
Miguel
Re: GLCD and Touchpad Library
Posted: Wed Jul 04, 2012 3:36 pm
by miguelmoreto
I forgot to say that I placed a lcdClear(Red); inside main loop in order to update the LCD constantly and monitoring the FSMC pins with a scope.
regards,
Miguel
Re: GLCD and Touchpad Library
Posted: Wed Jul 04, 2012 5:25 pm
by Abhishek
Hi miguel,
What are the logic levels observed with the scope on the various pins during the operation?
Abhishek
Re: GLCD and Touchpad Library
Posted: Wed Jul 04, 2012 5:29 pm
by Anubirux
I understand that you've check it with oscilloscope or logic analyzer, em I right ? What is your command/data and CS? Can you check FSMC registers and post it ?
@Abhishek you were faster ;d
Re: GLCD and Touchpad Library
Posted: Wed Jul 04, 2012 5:51 pm
by Abhishek
@miguel,
You mentioned earlier that you got LCD to work with non chibiOS code. I understand, you must be using ST lib to configure FSMC?
If that's the case, I suspect something wrong with FSMC init. Maybe the MCU is throwing in data so fast that the LCD is not able to take up. The code I see is much like what Badger uses. Maube a small delay is what is missing in the init. My suggestion at this point will be to review FSMC init. If in doubt, maybe could consult ref manual and ST lib code.
Best Regards
Abhishek