Jump to content

GunterO

Members
  • Posts

    32
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi Ivan47, There is an easy to use, Keil ready sample for the same setup you have online (http://jopl.dlnet.us/graphlcdarm.php) I made a quick connection with the LCD board I have (TFT_320QVT, same controller chips) and it works fine. I had to make some changes in the XPT2046/ADS7846 conversion routine, but that was quite easy. Made a video: https://drive.google.com/file/d/0B3B79f ... sp=sharing I hope it helps!
  2. Hi, I have some early experience with Keil µVision, ChibiOS/RT and µGFX. I've put a ready-to-compile sample online, with everything you need inside. It works fine on µVision v5.13 It's based on ChibiOS/RT 2.6.7 & a very recent copy of the Master branch of µGFX. Please share your mind-blowing stuff you make with it afterwards http://www.otte.be/stm32/20150320_STM3232F429I-DISCO_ChibiOS_uGFX_Sample.rar
  3. Ok, found all the info I need about the alternate GPIO functions in the data sheet of the STM32F405xx/STM32F407xx chip. Now it makes (more) sense to me :-)
  4. Hi, This is what I made of it. Feel free to optimize it :-) This file is working for all my situations. I have one question dough. For the Nucleo board (STM32L152RE), I can use a max clock speed of 8MHz (SPI_BaudRatePrescaler_4) for SPI2. For SPI1, 16MHz (SPI_BaudRatePrescaler_2) is working fine. Could be something wrong with the pin setup? I'm not 100% sure about the PAL_MODE_ALTERNATE(5) pin mode for the SPI pins. For instance, with the STM32F4-Discovery board, I need to use PAL_MODE_ALTERNATE(5) for SPI2 and PAL_MODE_ALTERNATE(6) for SPI3. Can you point me to a good document/tutorial where these pin modes are properly explained? Thanks! /* * This file is subject to the terms of the GFX License. If a copy of * the license was not distributed with this file, you can obtain one at: * * http://ugfx.org/license.html * * Altered, optimized an polished by Gunter Otté */ #ifndef _GDISP_LLD_BOARD_H #define _GDISP_LLD_BOARD_H #if defined(USE_STDPERIPH_DRIVER) // *** Use Tilen Majerle's libraries. This definition is usually specified by the compiler (well, for Keil it is :-)) #include "tm_stm32f4_ili9341.h" #else // *** Use ChibiOS/RT //**** ILI9341 on SPI. TESTED on STM32L1 AND STM32F4. // SPI communication method #define SPI_METHOD_IRQ 1 #define SPI_METHOD_POLLING 2 #define SPI_METHOD SPI_METHOD_POLLING // Target selection #define TARGET_SELECTION_NUCLEO_SPI1 1 #define TARGET_SELECTION_NUCLEO_SPI2 2 #define TARGET_SELECTION_DISCOVERY_SPI3 3 #define TARGET_SELECTION TARGET_SELECTION_NUCLEO_SPI1 #if TARGET_SELECTION == TARGET_SELECTION_NUCLEO_SPI1 // SPI_BaudRatePrescaler_2 tested OK #define SPI_DRIVER (&SPID1) #define SPI_PORT GPIOA #define SCK_PAD 5 //PA5 #define MISO_PAD 6 //PA6 #define MOSI_PAD 7 //PA7 #define CS_PORT GPIOA #define RESET_PORT GPIOA #define DNC_PORT GPIOA #define CS_PAD 4 // 0 = chip selected #define RESET_PAD 1 // 0 = reset #define DNC_PAD 0 // control=0, data=1 -- DNC or D/C #elif TARGET_SELECTION == TARGET_SELECTION_NUCLEO_SPI2 // For some reason, SPI_BaudRatePrescaler_4 is max for SPI2 #define SPI_DRIVER (&SPID2) #define SPI_PORT GPIOB #define SCK_PAD 13 //PB13 #define MISO_PAD 14 //PB14 #define MOSI_PAD 15 //PB15 #define CS_PORT GPIOA #define RESET_PORT GPIOA #define DNC_PORT GPIOA #define CS_PAD 4 // 0 = chip selected #define RESET_PAD 1 // 0 = reset #define DNC_PAD 0 // control=0, data=1 -- DNC or D/C #elif TARGET_SELECTION == TARGET_SELECTION_DISCOVERY_SPI3 // SPI_BaudRatePrescaler_2 tested OK // Pin & SPI setup #define SPI_DRIVER (&SPID3) #define SPI_PORT GPIOB #define SCK_PAD 3 //PB3 #define MISO_PAD 4 //PB4 #define MOSI_PAD 5 //PB5 #define CS_PORT GPIOC #define RESET_PORT GPIOD #define DNC_PORT GPIOD #define CS_PAD 2 // 0 = chip selected #define RESET_PAD 12 // 0 = reset #define DNC_PAD 13 // control=0, data=1 -- DNC or D/C #endif // SPI setup ajust " SPI_BaudRatePrescaler_X" to set SPI speed. // Peripherial Clock STM32F4-Discovery SPI1:84MHz, SPI2&SPI3:42MHz // Peripherial Clock STM32L152RE-Nucleo SPI1:32MHz // STM32F4-Discovery STM32L152RE-Nucleo // SPI1 SPI2/3 SPI1 #define SPI_BaudRatePrescaler_2 ((uint16_t)0x0000) // 42 MHz 21 MHZ 16 MHz #define SPI_BaudRatePrescaler_4 ((uint16_t)0x0008) // 21 MHz 10.5 MHz 8 MHz #define SPI_BaudRatePrescaler_8 ((uint16_t)0x0010) // 10.5 MHz 5.25 MHz 4 MHz #define SPI_BaudRatePrescaler_16 ((uint16_t)0x0018) // 5.25 MHz 2.626 MHz 2 MHz #define SPI_BaudRatePrescaler_32 ((uint16_t)0x0020) // 2.626 MHz 1.3125 MHz 1 MHz #define SPI_BaudRatePrescaler_64 ((uint16_t)0x0028) // 1.3125 MHz 656.25 KHz 500 KHz #define SPI_BaudRatePrescaler_128 ((uint16_t)0x0030) // 656.25 KHz 328.125 KHz 250 KHz #define SPI_BaudRatePrescaler_256 ((uint16_t)0x0038) // 328.125 KHz 164.06 KHz 125 KHz static SPIConfig spi_cfg = { NULL, CS_PORT, CS_PAD, SPI_BaudRatePrescaler_2 //Ajust speed here. It's quite unlikely that the ILI9341 can handle >21MHz clock ... }; #endif #include "gfx.h" static __inline void init_board(GDisplay *g) { (void) g; g->board = 0; #if defined(USE_STDPERIPH_DRIVER) TM_ILI9341_Init(); #else //Set up the pins.. palSetPadMode(CS_PORT, CS_PAD, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); #if (TARGET_SELECTION == TARGET_SELECTION_NUCLEO_SPI1) || (TARGET_SELECTION == TARGET_SELECTION_NUCLEO_SPI2) palSetPadMode(SPI_PORT, SCK_PAD, PAL_MODE_ALTERNATE(5) | PAL_STM32_OSPEED_HIGHEST); palSetPadMode(SPI_PORT, MISO_PAD, PAL_MODE_ALTERNATE(5)); palSetPadMode(SPI_PORT, MOSI_PAD, PAL_MODE_ALTERNATE(5) | PAL_STM32_OSPEED_HIGHEST); #elif TARGET_SELECTION == TARGET_SELECTION_DISCOVERY_SPI3 palSetPadMode(SPI_PORT, SCK_PAD, PAL_MODE_ALTERNATE(6) | PAL_STM32_OSPEED_HIGHEST); palSetPadMode(SPI_PORT, MISO_PAD, PAL_MODE_ALTERNATE(6)); palSetPadMode(SPI_PORT, MOSI_PAD, PAL_MODE_ALTERNATE(6) | PAL_STM32_OSPEED_HIGHEST); #endif palSetPadMode(DNC_PORT, DNC_PAD, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); palSetPadMode(RESET_PORT, RESET_PAD, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); //Set pins. palSetPad(CS_PORT, CS_PAD); palSetPad(RESET_PORT, RESET_PAD); palClearPad(DNC_PORT, DNC_PAD); //Start SPI with our config. spiStart(SPI_DRIVER, &spi_cfg); spiSelectI(SPI_DRIVER); /* Slave Select assertion. */ #endif } static __inline void post_init_board(GDisplay *g) { (void) g; } static __inline void setpin_reset(GDisplay *g, bool_t state) { (void) g; #if defined(USE_STDPERIPH_DRIVER) if(state == 1){ ILI9341_RST_RESET;} else { ILI9341_RST_SET; } #else palWritePad(RESET_PORT, RESET_PAD, !state); #endif } static __inline void set_backlight(GDisplay *g, uint8_t percent) { (void) g; (void) percent; } static __inline void acquire_bus(GDisplay *g) { (void) g; #if defined(USE_STDPERIPH_DRIVER) #else spiSelectI(SPI_DRIVER); #endif } static __inline void release_bus(GDisplay *g) { (void) g; #if defined(USE_STDPERIPH_DRIVER) #else spiUnselectI(SPI_DRIVER); #endif } static __inline void write_index(GDisplay *g, uint8_t index) { (void) g; #if defined(USE_STDPERIPH_DRIVER) TM_ILI9341_SendCommand(index); #else palClearPad(DNC_PORT, DNC_PAD); #if SPI_METHOD == SPI_METHOD_IRQ spiSend(SPI_DRIVER, 1, &index); #elif SPI_METHOD == SPI_METHOD_POLLING spiPolledExchange(SPI_DRIVER, index); #endif palSetPad(DNC_PORT, DNC_PAD); #endif } static __inline void write_data(GDisplay *g, uint8_t data) { (void) g; #if defined(USE_STDPERIPH_DRIVER) TM_ILI9341_SendData(data); #else #if SPI_METHOD == SPI_METHOD_IRQ spiSend(SPI_DRIVER, 1, &data); #elif SPI_METHOD == SPI_METHOD_POLLING spiPolledExchange(SPI_DRIVER, data); #endif #endif } static __inline void setreadmode(GDisplay *g) { (void) g; } static __inline void setwritemode(GDisplay *g) { (void) g; } static __inline uint16_t read_data(GDisplay *g) { (void) g; return 0; } #endif /* _GDISP_LLD_BOARD_H */
  5. Yeah, sure, would be great! I just want to polish the board file a little bit more so it is usable for multiple targets. Now I have a version for the Nucleo, and two for the STM32F4-Discovery (one based on ChibiOS and one on Tilen Majerle's libraries (bare metal, no RTOS)), and I want to merge them in a sort of easy to understand way for users who want to use it in different configurations.
  6. While porting this to the STM32F4-Discovery board, I found an error/typo in the board file. Took me a while to find it , so I want to save you the time in case you want to do the same or use a pin from another port ... //Set up the pins.. palSetPadMode(SPI_PORT, CS_PAD, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); needs to be of course: //Set up the pins.. palSetPadMode(CS_PORT, CS_PAD, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
  7. Sure, you can find it here: http://www.otte.be/stm32/20150318_STM32F4-DISCO_uGFX.rar Didn't use something like WeTransfer so the download will be available for a longer time. All is include, to make sure it builds as it should be in Keil µVision (I used v5.13). I kept the naming scheme from Tilen Majerle (http://stm32f4-discovery.com/) and didn't move any of his or µGFX's library files around. The LCD is something like this: http://www.benl.ebay.be/itm/2-2-inch-2-2-SPI-TFT-LCD-Display-module-240x320-ILI9341-51-AVR-STM32-ARM-PIC-/200939222521?pt=LH_DefaultDomain_0&hash=item2ec8e935f9 Connected like this: LCD STM32F4-Discovery ---------------------------- SCK -> B3 MISO -> B4 (not used) MOSI -> B5 CS -> C2 RST -> D12 DC/RS -> D13 Added a video: https://drive.google.com/file/d/0B3B79fgnqTCaWXU4N3lSX1VKRHM/view?usp=sharing
  8. Well, the 21MHz is working with short dupont wires. I measured with a scope, and the SPI clock is indeed 21MHz, but the clock wave is looking like a sinus/triangle wave. I guess it is probably the maximum we can hope for
  9. Yep, there was the problem with the board file indeed. Those functions are expecting a byte, not a word. Anyway, now it is working perfect with µGFX. Another project working in my examples folder And I must say, even a lot faster then on the STM32L152RE-Nucleo board, but that was expected because of the high clock of the STM32F4-Discovery board. Maybe you can try to use SPI1, because it can run @ 42MHz (BaudRatePrescaler_4), while the max frequency for SPI2 & SPI3 is 21MHz (BaudRatePrescaler_8). I wonder how much this ILI9341 can take
  10. Hi Ivan, I've send you the project via WeTransfer (you should have received an e-mail about this). It compiles (no worries about the µGFX warnings, I have the same with my working projects). However, there is something wrong with your board_ILI9341.h file. I don't think you can just add the stuff from tm_stm32f4_ili9341.h and hope it works. Maybe you can look at my board file from here http://forum.ugfx.org/viewtopic.php?f=23&t=175&start=20#p1364 and see if it gets you any further. That board file is based on the ChibiOS/RT HAL, but maybe it can help you. I might look into this further when I have some spare time. Good luck!
  11. Well, no, sorry. I noticed it before in your comments, but the company is called Keil, not Kiel. So the definition needs to be "__KEIL__" and not "__KIEL__"
  12. I have your project compiling here, but I still need to test it with the board/LCD, will do this evening. If you want, I can send you the project, or you wait until I did some testing.
  13. Not really, because setjmp is defined by Keil (\ARM\ARMCC\include\setjmp.h), so it never reaches the #define _setjmp setjmp and gos_raw32.c needs _setjmp() #if !defined(__KEIL__) && !defined(__C51__) #ifndef setjmp #ifndef _setjmp #define _setjmp setjmp #endif #endif #ifndef longjmp #ifndef _longjmp #define _longjmp longjmp #endif #endif #endif Something like this would work better for me: #if !defined(__KEIL__) && !defined(__C51__) #if !defined(setjmp) && !defined(_setjmp) #define _setjmp setjmp #endif #if !defined(longjmp) && !defined(_longjmp) #define _longjmp longjmp #endif #else #if !defined(_setjmp) #define _setjmp setjmp #endif #if !defined(_longjmp) #define _longjmp longjmp #endif #endif Sorry, but one more issue/error I forgot about. Because of this error, I commented out this (src/gos/gos_raw32.h) : typedef char int8_t; #ifndef _STDINT_H // typedef char int8_t; typedef unsigned char uint8_t; typedef short int16_t; typedef unsigned short uint16_t; typedef int int32_t; typedef unsigned int uint32_t; #endif This would work: #ifndef _STDINT_H #if !defined(__KEIL__) && !defined(__C51__) typedef char int8_t; #endif typedef unsigned char uint8_t; typedef short int16_t; typedef unsigned short uint16_t; typedef int int32_t; typedef unsigned int uint32_t; #endif But maybe I'm missing something? Thanks!
  14. Hi, thanks for your reply. Yes, I found a possible issue with it. More details here: http://forum.ugfx.org/viewtopic.php?f=23&t=183 Maybe you can put a fix inside a #if defined(__KEIL__) ... #endif thing specific for µVision?
  15. Hello, I'm trying to get µGFX running on bare metal while using Keil µVision 5.13. I have almost everything compiling, except 1 problem with _setjmp(): in gos_raw32.c this is defined: #include /* jmp_buf, setjmp(), longjmp() */ #ifndef setjmp #ifndef _setjmp #define _setjmp setjmp #endif #endif setjmp.h is coming from \Keil_v5\ARM\ARMCC\include\setjmp.h Here is already setjmp defined: #define setjmp(jmp_buf) (__CLIBNS setjmp(jmp_buf)) What am I doing wrong? I have the option to comment out the #ifndef setjmp .. #endif from gos_raw32.c, then it compiles, but I don't want to mess in that code. Anybody an idea what I do best? Thanks!
×
×
  • Create New...