Jump to content

LeMoussel

Members
  • Posts

    21
  • Joined

  • Last visited

Everything posted by LeMoussel

  1. I did what you said. Screen is white & uGFX startup logo is not displayed
  2. Wel, well ... I'm confused :oops: It'OK. Thank you.
  3. In gfxconf.h, I enable the following settings: when linking, I got this error [cc] Starting link [cc] arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -g -nostartfiles -Wl,-Map=Test_uGFX.map -O0 -Wl,--gc-sections -LD:\Applications\CooCox\CoIDE\configuration\ProgramData\Test_uGFX -Wl,-TD:\Applications\CooCox\CoIDE\configuration\ProgramData\Test_uGFX/arm-gcc-link.ld -g -o Test_uGFX.elf ..\obj\DejaVuSans32.o ..\obj\stm32f10x_rtc.o ..\obj\fixed_10x20.o ..\obj\stm32f10x_tim.o ..\obj\LargeNumbers.o ..\obj\DejaVuSansBold12_aa.o ..\obj\mf_scaledfont.o ..\obj\stm32f10x_dbgmcu.o ..\obj\system_stm32f10x.o ..\obj\gdisp_lld_ILI9325.o ..\obj\image_bmp.o ..\obj\stm32f10x_fsmc.o ..\obj\stm32f10x_pwr.o ..\obj\startup_stm32f10x_md.o ..\obj\win32.o ..\obj\stm32f10x_can.o ..\obj\chibios.o ..\obj\stm32f10x_gpio.o ..\obj\stm32f10x_dac.o ..\obj\image_jpg.o ..\obj\UI1.o ..\obj\osx.o ..\obj\main.o ..\obj\DejaVuSans16_aa.o ..\obj\image_native.o ..\obj\fixed_5x8.o ..\obj\UI2.o ..\obj\image_gif.o ..\obj\stm32f10x_crc.o ..\obj\mf_font.o ..\obj\DejaVuSansBold12.o ..\obj\mf_rlefont.o ..\obj\mf_bwfont.o ..\obj\stm32f10x_rcc.o ..\obj\freertos.o ..\obj\fixed_7x14.o ..\obj\stm32f10x_exti.o ..\obj\DejaVuSans10.o ..\obj\stm32f10x_adc.o ..\obj\fonts.o ..\obj\mf_encoding.o ..\obj\stm32f10x_usart.o ..\obj\DejaVuSans12.o ..\obj\DejaVuSans32_aa.o ..\obj\syscalls.o ..\obj\stm32f10x_flash.o ..\obj\mf_justify.o ..\obj\stm32f10x_cec.o ..\obj\linux.o ..\obj\stm32f10x_sdio.o ..\obj\DejaVuSans16.o ..\obj\stm32f10x_dma.o ..\obj\gdisp.o ..\obj\image_png.o ..\obj\gfx.o ..\obj\misc.o ..\obj\DejaVuSans24.o ..\obj\stm32f10x_wwdg.o ..\obj\stm32f10x_spi.o ..\obj\mf_wordwrap.o ..\obj\raw32.o ..\obj\stm32f10x_i2c.o ..\obj\image.o ..\obj\DejaVuSans12_aa.o ..\obj\stm32f10x_bkp.o ..\obj\DejaVuSans24_aa.o ..\obj\mf_kerning.o ..\obj\stm32f10x_iwdg.o -lm -lgcc -lc [cc] ..\obj\DejaVuSans16.o:(.rodata+0x728): multiple definition of `mf_rlefont_DejaVuSans16' [cc] ..\obj\mf_font.o:(.rodata+0x728): first defined here [cc] collect2.exe: error: ld returned 1 exit status thanks for your help
  4. I do not understand what I need to do more that inmarket has suggested. I directly put LCD_Init() code into post_init_board(). board_ILI9325.h /* * 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 */ #ifndef GDISP_LLD_BOARD_H #define GDISP_LLD_BOARD_H #include #define _STDINT_H // IO port operations macro definition #define BITBAND(addr, bitnum) ((addr & 0xF0000000)+0x2000000+((addr &0xFFFFF)<<5)+(bitnum<<2)) #define MEM_ADDR(addr) *((volatile unsigned long *)(addr)) #define BIT_ADDR(addr, bitnum) MEM_ADDR(BITBAND(addr, bitnum)) // LCD control pin configuration #define GPIOC_ODR_Addr (GPIOC_BASE+12) //0x4001100C #define PCout(n) BIT_ADDR(GPIOC_ODR_Addr,n) #define LCD_CS PCout(8) #define LCD_RS PCout(9) #define LCD_WR PCout(10) #define LCD_RD PCout(11) #include "stm32f10x.h" static inline void write_index(GDisplay *g, uint16_t index); static inline void write_data(GDisplay *g, uint16_t data); static inline void write_reg(GDisplay *g, uint16_t reg, uint16_t data); static inline uint16_t read_reg(GDisplay *g, uint16_t reg); static inline void init_board(GDisplay *g) { (void) g; } static inline void post_init_board(GDisplay *g) { (void) g; GPIO_InitTypeDef GPIO_InitStructure; uint16_t DeviceCode; // Open the clock RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC,ENABLE); // Configuration data IO connected to GPIOB GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // Push-pull output GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; // Output IO ports for maximum speed 50MHZ GPIO_Init(GPIOB, &GPIO_InitStructure); // Configuration Control IO connected to PD12.PD13.PD14.PD15/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOC, &GPIO_InitStructure); write_reg(g, 0x0000, 0x0001); gfxSleepMilliseconds(50); DeviceCode = read_reg(g, 0x0000); //LCD_ReadReg(0x0000); // Check if the LCD is ILI9325 Controller if(DeviceCode == 0x9325 || DeviceCode == 0x9328) { write_reg(g,0x00e5,0x78F0); /* Start Initial Sequence ------------------------------------------------*/ write_reg(g,0x0001,0x0100); // Driver output control (makes it scan top left to bottom right, odd for top half, even for bottom) write_reg(g,0x0002,0x0700); // Line inversion on the LCD Driving Wave Control write_reg(g,0x0003,0x1030); // Entry mode set. Set GRAM write direction and BGR=1. write_reg(g,0x0004,0x0000); // Resizing register write_reg(g,0x0008,0x0202); // (Display control 2) Set 2 lines for both front and back porch (minimum number, helps VSYNC) write_reg(g,0x0009,0x0000); // (Display control 3) Sets 0 frame scan cycle and normal scan. Set non-display area refresh cycle ISC[3] write_reg(g,0x000a,0x0000); // FMARK signal function write_reg(g,0x000c,0x0001); // 16-bit RGB interface (1 transfer/pixel), using internal system clock and system interface write_reg(g,0x000d,0x0000); // Frame Marker at position 0 (starts outputting frame right away) write_reg(g,0x000f,0x0000); // RGB interface polarit. Data input on rising edge of DOTCLK, data written when ENABLE=0,HSPL/VSPL(H/VSYNC pins) Low polarit = active /* Power On sequence -----------------------------------------------------*/ write_reg(g,0x0010,0x0000); // (Power control 1) Enable power supply write_reg(g,0x0011,0x0007); // (Power control 2) Ref. voltage(VciOUT) = Vci1, operating frequency = Fosc in circuit 1 and Fosc/16 in circuit 2 write_reg(g,0x0012,0x0000); // (Power control 3) Enable VGL output, use internal electric volume(VCM) to set VcomH(Vcom center voltage level write_reg(g,0x0013,0x0000); // (Power control 4) VCOM Amplitude = VREG1OUT x 0.90 write_reg(g,0x0007,0x0001); // (Display control 1) Set display to operate, VCOM output to GND gfxSleepMilliseconds(50); // Delay 50ms write_reg(g,0x0010,0x1690); // (Power control 1) Enable power supply(0x10c0) write_reg(g,0x0011,0x0227); gfxSleepMilliseconds(50); write_reg(g,0x0012,0x009d); gfxSleepMilliseconds(50); write_reg(g,0x0013,0x1900); // (Power control 4) VCOM Amplitude = VREG1OUT x 0.90 write_reg(g,0x0029,0x0025); // (Power control 7) VcomH voltage = VREG1OUT x .69 write_reg(g,0x002b,0x000d); // ??Hz frame rate, internal resistor. gfxSleepMilliseconds(50); write_reg(g,0x0020,0x0000); // GRAM horizontal Address write_reg(g,0x0021,0x0000); // GRAM Vertical Address */ gfxSleepMilliseconds(50); write_reg(g,0x0030,0x0007); write_reg(g,0x0031,0x0303); write_reg(g,0x0032,0x0003); write_reg(g,0x0035,0x0206); write_reg(g,0x0036,0x0008); write_reg(g,0x0037,0x0406); write_reg(g,0x0038,0x0304); write_reg(g,0x0039,0x0007); write_reg(g,0x003c,0x0602); write_reg(g,0x003d,0x0008); gfxSleepMilliseconds(50); write_reg(g,0x0050,0x0000); // Set X Star. X starts at 0. write_reg(g,0x0051,0x00ef); // Set X End. X ends at 239. write_reg(g,0x0052,0x0000); // Set Y Star. Y starts at 0. write_reg(g,0x0053,0x013f); // Set Y End. Y ends at 319. write_reg(g,0x0060,0xa700); // (Driver output control) Gate scans at 0, ends after 320 lines write_reg(g,0x0061,0x0001); // (Driver output control) grayscale inversion. write_reg(g,0x006a,0x0000); // (Vertical scroll control) not used write_reg(g,0x0080,0x0000); // Display position for partial image 1 write_reg(g,0x0081,0x0000); // RAM address for start of partial image 1 write_reg(g,0x0082,0x0000); // RAM address for end of partial image 1 write_reg(g,0x0083,0x0000); // Display position for partial image 2 write_reg(g,0x0084,0x0000); // RAM address for start of partial image 2 write_reg(g,0x0085,0x0000); // RAM address for end of partial image 2 write_reg(g,0x0090,0x0010); // (Panel interface control 1) Sets clock number for internal clock write_reg(g,0x0092,0x0600); // (Panel interface control 2) 0 Clocks of overlap when synced write_reg(g,0x0007,0x0133); // (Display control 1) Set display to operate, base image display, normal display } } static inline void setpin_reset(GDisplay *g, bool_t state) { (void) g; (void) state; } static inline void set_backlight(GDisplay *g, uint8_t percent) { (void) g; (void) percent; } static inline void acquire_bus(GDisplay *g) { (void) g; } static inline void release_bus(GDisplay *g) { (void) g; } static inline void write_index(GDisplay *g, uint16_t index) { (void) g; LCD_CS = 0; LCD_RS = 0; GPIOC->ODR = (GPIOC->ODR & 0xff00) | (index & 0x00ff); GPIOB->ODR = (GPIOB->ODR & 0x00ff) | (index & 0xff00); LCD_WR = 0; LCD_WR = 1; LCD_CS = 1; } static inline void write_data(GDisplay *g, uint16_t data) { (void) g; LCD_CS = 0; LCD_RS = 1; GPIOC->ODR = (GPIOC->ODR & 0xff00) | (data & 0x00ff); GPIOB->ODR = (GPIOB->ODR & 0x00ff) | (data & 0xff00); LCD_WR = 0; LCD_WR = 1; LCD_CS = 1; } static inline void write_reg(GDisplay *g, uint16_t reg, uint16_t data) { write_index(g, reg); write_data(g, data); } static inline uint16_t read_reg(GDisplay *g, uint16_t reg) { uint16_t value; write_index(g, reg); // configure pins for reading GPIOB->CRH = (GPIOB->CRH & 0x00000000) | 0x44444444; GPIOC->CRL = (GPIOC->CRL & 0x00000000) | 0x44444444; LCD_CS = 0; LCD_RS = 1; LCD_RD = 0; value = ((GPIOB->IDR&0xff00)|(GPIOC->IDR&0x00ff)); LCD_RD = 1; LCD_CS = 1; // reconfigure back to normal operation GPIOB->CRH = (GPIOB->CRH & 0x00000000) | 0x33333333; GPIOC->CRL = (GPIOC->CRL & 0x00000000) | 0x33333333; return value; } 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. I use base C library If I do static inline void init_board(GDisplay *g) { (void) g; } static inline void post_init_board(GDisplay *g) { (void) g; LCD_Init(); } with no call to LCD_Init() in main program, I see uGFX startup logo & background display is green Strange Not ?
  6. when you manually issue the LCD_Init() routine after gfxInit(), you still use your board file to write the data, right? Yes. Do you still have the LCD_Init() routine within the init_board() routine? Yes. LCD_Init() get executed when init_board() is being called. static inline void init_board(GDisplay *g) { // As we are not using multiple displays we set g->board to NULL as we don't use it. g->board = 0; switch(g->controllerdisplay) { case 0: // Set up for Display 0 LCD_Init(); break; } }
  7. in init_board(GDisplay *g) "g" 0x2000085c g {...} Width 0 Height 0 Orientation GDISP_ROTATE_0 Powermode powerOff Backlight 0 Contrast 0 priv 0x00000000 board 0x00000000 systemdisplay 0 controllerdisplay 0 flags 0 clipx0 0 clipy0 0 clipx1 0 clipy1 0 p {...} x 0 y 0 cx 0 cy 0 x1 0 y1 0 x2 0 y2 0 color 0 ptr 0x00000000 in gdispGClear(GDisplay *g, color_t color) "g" 0x2000085c g {...} Width 240 Height 320 Orientation GDISP_ROTATE_0 Powermode powerOn Backlight 'd' Contrast '2' priv 0x00000000 board 0x00000000 systemdisplay 0 controllerdisplay 0 flags 0 clipx0 0 clipy0 0 clipx1 240 clipy1 320 p {...} x 0 y 0 cx 240 cy 320 x1 0 y1 0 x2 0 y2 0 color 0 ptr 0x00000000
  8. Hi all, I am using the STM32F103 board with 240x320 TFT (ILI9325). I use uGFX in GOS port mode. In file board_ILI9325.h, I use the STM stdperiph library functions to control ILI9325 peripheral. But I have a small problem. With this code there is no display. int main(void) { coord_t width, height; /* Setup STM32 system (clock, PLL and Flash configuration) */ SystemInit(); gfxInit(); // Get the screen size width = gdispGetWidth(); height = gdispGetHeight(); gdispClear(Green); while(TRUE) { gfxSleepMilliseconds(1000); // Wait 1 Sec; } } board_ILI9325.h static inline void init_board(GDisplay *g) { // As we are not using multiple displays we set g->board to NULL as we don't use it. g->board = 0; switch(g->controllerdisplay) { case 0: // Set up for Display 0 LCD_Init(); break; } } static inline void write_index(GDisplay *g, uint16_t index) { (void) g; LCD_CS = 0; LCD_RS = 0; GPIOC->ODR = (GPIOC->ODR & 0xff00) | (index & 0x00ff); GPIOB->ODR = (GPIOB->ODR & 0x00ff) | (index & 0xff00); LCD_WR = 0; LCD_WR = 1; LCD_CS = 1; } static inline void write_data(GDisplay *g, uint16_t data) { (void) g; LCD_CS = 0; LCD_RS = 1; GPIOC->ODR = (GPIOC->ODR & 0xff00) | (data & 0x00ff); GPIOB->ODR = (GPIOB->ODR & 0x00ff) | (data & 0xff00); LCD_WR = 0; LCD_WR = 1; LCD_CS = 1; } But with this code, background display is green ! int main(void) { coord_t width, height; /* Setup STM32 system (clock, PLL and Flash configuration) */ SystemInit(); gfxInit(); LCD_Init(); // Get the screen size width = gdispGetWidth(); height = gdispGetHeight(); gdispClear(Green); while(TRUE) { gfxSleepMilliseconds(1000); // Wait 1 Sec; } }
  9. Yep with the gfxinit () call, It's OK 8-) Thanks for your help. Final source code : /* Includes ------------------------------------------------------------------*/ #include "stm32f10x_conf.h" // https://bitbucket.org/Tectu/ugfx/src/a61b4a71159f?at=master #include "gfx.h" #include "hardware.h" /* Private function prototypes -----------------------------------------------*/ systemticks_t gfxSystemTicks(void); systemticks_t gfxMillisecondsToTicks(delaytime_t ms); // LED Definitions #define LED1 PAout(2) // on the board corresponds to LED1 #define LED2 PAout(3) // on the board corresponds to LED2 void GPIO_Configuration(void); void SysTick_Handler(void); static volatile uint32_t TimingDelay = 0; /** * @brief Main program. * @param None * @retval None */ int main(void) { /* Setup STM32 system (clock, PLL and Flash configuration) */ SystemInit(); /* Enable port GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG and AFIO clocks */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG | RCC_APB2Periph_AFIO | RCC_APB2Periph_ADC1, ENABLE); /* DMA1 and DMA2 clock enable */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1 | RCC_AHBPeriph_DMA2, ENABLE); /* SystemCoreClock is 72000000Hz (72MHz) */ /* Setup SysTick Timer for 1 msec interrupts */ while(SysTick_Config(SystemCoreClock / 1000)); GPIO_Configuration(); // Initialize UGfx gfxInit(); while(TRUE) { LED1 = 1; // Turn on LED 1. LED2 = 0; // Turn off LED 2. gfxSleepMilliseconds(1000); // Wait 1 Sec; LED1 = !LED1; // Turn off LED 1. LED2 = !LED2; // Turn on LED 2. gfxSleepMilliseconds(1000); // Wait 1 Sec; } } /** * @brief This function handles SysTick Handler. * @param None * @retval : None */ void SysTick_Handler(void) { TimingDelay++; } /** * @brief Configure IO port. * @param None * @retval None */ void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3; // Configure LED1, LED2 pin functions GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // universal push-pull output GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; // maximum output frequency is 50MHz GPIO_Init (GPIOA, & GPIO_InitStructure); // initialization PA2, PA3 } /** * @brief Gets a "tick" time from the hardware. * @param None * @retval a "tick" time */ systemticks_t gfxSystemTicks(void) { return TimingDelay; } /** * @brief Converts a number of milliseconds to a number of ticks. * @param None * @retval number of ticks */ systemticks_t gfxMillisecondsToTicks(delaytime_t ms) { return ms; }
  10. I do this /* Includes ------------------------------------------------------------------*/ #include "stm32f10x_conf.h" // https://bitbucket.org/Tectu/ugfx/src/a61b4a71159f?at=master #include "gfx.h" #include "hardware.h" /* Private function prototypes -----------------------------------------------*/ systemticks_t gfxSystemTicks(void); systemticks_t gfxMillisecondsToTicks(delaytime_t ms); // LED Definitions #define LED1 PAout(2) // on the board corresponds to LED1 #define LED2 PAout(3) // on the board corresponds to LED2 void GPIO_Configuration(void); void TestgfxSleepMilliseconds(delaytime_t ms); void SysTick_Handler(void); static volatile uint32_t TimingDelay = 0; /** * @brief Main program. * @param None * @retval None */ int main(void) { /* Setup STM32 system (clock, PLL and Flash configuration) */ SystemInit(); /* Enable port GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG and AFIO clocks */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG | RCC_APB2Periph_AFIO | RCC_APB2Periph_ADC1, ENABLE); /* DMA1 and DMA2 clock enable */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1 | RCC_AHBPeriph_DMA2, ENABLE); /* SystemCoreClock is 72000000Hz (72MHz) */ /* Setup SysTick Timer for 1 msec interrupts */ while(SysTick_Config(SystemCoreClock / 1000)); GPIO_Configuration(); while(TRUE) { LED1 = 1; // Turn on LED 1. LED2 = 0; // Turn off LED 2. // Wait 1 Sec TestgfxSleepMilliseconds(1000); // OK gfxSleepMilliseconds(1000); // KO no Return LED1 = !LED1; // Turn off LED 1. LED2 = !LED2; // Turn on LED 2. TestgfxSleepMilliseconds(1000); } } void TestgfxSleepMilliseconds(delaytime_t ms) { systemticks_t currenttm, starttm, delay; // Convert delay to ticks delay = gfxMillisecondsToTicks(ms); starttm = gfxSystemTicks(); do { currenttm = gfxSystemTicks(); } while (currenttm - starttm < delay); } /** * @brief This function handles SysTick Handler. * @param None * @retval : None */ void SysTick_Handler(void) { TimingDelay++; } /** * @brief Configure IO port. * @param None * @retval None */ void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3; // Configure LED1, LED2 pin functions GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // universal push-pull output GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; // maximum output frequency is 50MHz GPIO_Init (GPIOA, & GPIO_InitStructure); // initialization PA2, PA3 } /** * @brief Gets a "tick" time from the hardware. * @param None * @retval a "tick" time */ systemticks_t gfxSystemTicks(void) { return TimingDelay; } /** * @brief Converts a number of milliseconds to a number of ticks. * @param None * @retval number of ticks */ systemticks_t gfxMillisecondsToTicks(delaytime_t ms) { return ms; } It's OK with me test function TestgfxSleepMilliseconds() but KO with gfxSleepMilliseconds() gfxSleepMilliseconds(...) can't return. This seems to be in gfxYield() function in this line void gfxYield(void) { if (!_setjmp(current->cxt)) { ..... Rem : I use the bare metal port without any underlying OS.
  11. inmarket, it seems that you are right when you say I suspect the tick timer has not been initialised correctly. I took the code of gfxSleepMilliseconds() in the following way void TestgfxSleepMilliseconds(delaytime_t ms) { systemticks_t currenttm, starttm, delay; // Convert delay to ticks delay = gfxMillisecondsToTicks(ms); starttm = gfxSystemTicks(); do { currenttm = gfxSystemTicks(); } while (currenttm - starttm < delay); } I do not know why the value in currenttm is always less than the value in starttm ! With this test that handle SysTick it's OK /* Includes ------------------------------------------------------------------*/ #include "stm32f10x_conf.h" // https://bitbucket.org/Tectu/ugfx/src/a61b4a71159f?at=master #include "gfx.h" #include "hardware.h" /* Private function prototypes -----------------------------------------------*/ systemticks_t gfxSystemTicks(void); systemticks_t gfxMillisecondsToTicks(delaytime_t ms); // LED Definitions #define LED1 PAout(2) // on the board corresponds to LED1 #define LED2 PAout(3) // on the board corresponds to LED2 void GPIO_Configuration(void); void TestgfxSleepMilliseconds(delaytime_t ms); void mygfxSleepMilliseconds(volatile uint32_t nTime); void SysTick_Handler(void); static volatile uint32_t TimingDelay; /** * @brief Main program. * @param None * @retval None */ int main(void) { coord_t width, height; /* SystemCoreClock is 72000000Hz (72MHz) */ /* Setup SysTick Timer for 1 msec interrupts */ while(SysTick_Config(SystemCoreClock / 1000)); GPIO_Configuration(); // Initialize and clear the display //gfxInit(); // Get the screen size //width = gdispGetWidth(); //height = gdispGetHeight(); //gdispClear(Green); while(TRUE) { LED1 = 1; // Turn on LED 1. LED2 = 0; // Turn off LED 2. // Wait 1 Sec mygfxSleepMilliseconds(1000); // OK //TestgfxSleepMilliseconds(1000); // KO LED1 = 0; // Turn off LED 1. LED2 = 1; // Turn on LED 2. mygfxSleepMilliseconds(1000); } } void TestgfxSleepMilliseconds(delaytime_t ms) { systemticks_t currenttm, starttm, delay; // Convert delay to ticks delay = gfxMillisecondsToTicks(ms); starttm = gfxSystemTicks(); do { currenttm = gfxSystemTicks(); } while (currenttm - starttm < delay); // Sick ! currenttm is always < starttm, Why ? } void mygfxSleepMilliseconds(volatile uint32_t nTime) { TimingDelay = nTime; while(TimingDelay != 0); } /** * @brief This function handles SysTick Handler. * @param None * @retval : None */ void SysTick_Handler(void) { if (TimingDelay != 0x00) { TimingDelay--; } } /** * @brief Configure IO port. * @param None * @retval None */ void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); // enable port, it is important! ! ! GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3; // Configure LED1, LED2 pin functions GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // universal push-pull output GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; // maximum output frequency is 50MHz GPIO_Init (GPIOA, & GPIO_InitStructure); // initialization PA2, PA3 } /** * @brief Gets a "tick" time from the hardware. * @param None * @retval a "tick" time */ systemticks_t gfxSystemTicks(void) { return SysTick->VAL; } /** * @brief Converts a number of milliseconds to a number of ticks. * @param None * @retval number of ticks */ systemticks_t gfxMillisecondsToTicks(delaytime_t ms) { return ms; }
  12. I tested the gfxSleepMilliseconds function with the following code int main(void) { GPIO_Configuration(); /* SystemCoreClock is 72000000Hz (72MHz) */ /* Set the HCLK Clock as SysTick clock source (72MHz) and Setup SysTick Timer for 1 msec interrupts */ SysTick_Config(SystemCoreClock / 1000); // Initialize and clear the display gfxInit(); while(TRUE) { LED1 = 1; // Turn on LED 1. LED2 = 0; // Turn off LED 2. gfxSleepMilliseconds(1000); // Wait 1 Sec; LED1 = 0; // Turn off LED 1. LED2 = 1; // Turn on LED 2. gfxSleepMilliseconds(1000); } } /** * @brief Gets a "tick" time from the hardware. * @param None * @retval a "tick" time */ systemticks_t gfxSystemTicks(void) { return SysTick->VAL; } /** * @brief Converts a number of milliseconds to a number of ticks. * @param None * @retval number of ticks */ systemticks_t gfxMillisecondsToTicks(delaytime_t ms) { return ms; } No LED blinking With this code LED blinking int main(void) { GPIO_Configuration(); while(TRUE) { LED1 = 1; // Turn on LED 1. LED2 = 0; // Turn off LED 2. Delay(5000); LED1 = 0; // Turn off LED 1. LED2 = 1; // Turn on LED 2. Delay(5000); } } void Delay(uint16_t time) { uint16_t i,j; for(i=time;i>0;i--) { for(j=500;j>0;j--); } } Do you have an idea why the LEDs do not blink with the use of gfxSleepMilliseconds()?
  13. So a timer at 72MHz gets 72 000 000 ticks per second. /** * @brief Converts a number of milliseconds to a number of ticks. * @param None * @retval a "tick" time */ systemticks_t gfxMillisecondsToTicks(delaytime_t ms) { uint32_t TicksPerSecond = 72000000; systemticks_t TicksPerMillisecond = TicksPerSecond / 1000; return ms * TicksPerMillisecond; } is this true?
  14. Well I find some systick API from the standard peripheral library to implement gfxSystemTicks(void) like this /** * @brief Gets a "tick" time from the hardware. * @param None * @retval a "tick" time */ systemticks_t gfxSystemTicks(void) { return SysTick->VAL; } And in main.c, I call SysTick_Config() function to initialize SysTick /** * @brief Main program. * @param None * @retval None */ int main(void) { coord_t width, height; /* Set the HCLK Clock as SysTick clock source (72MHz) */ /* Setup SysTick Timer for 1 msec interrupts */ SysTick_Config(72000000 / 1000); ..... If I understood for the gfxMillisecondsToTicks() function, you have to convert convert a number of milliseconds to a number of ticks.
  15. I copy the /drivers/gdisp/ILI9325/board_ILI9325_template.h file to board_ILI9325.h in the same directory as gfxconf.h file (in root project directory). I get this errors : [cc] ..\obj\raw32.o: In function `gfxSleepMilliseconds': [cc] D:\STM32F103 Projects\ugfx_lib\src\gos/raw32.c:381: undefined reference to `gfxMillisecondsToTicks' [cc] D:\STM32F103 Projects\ugfx_lib\src\gos/raw32.c:382: undefined reference to `gfxSystemTicks' [cc] D:\STM32F103 Projects\ugfx_lib\src\gos/raw32.c:386: undefined reference to `gfxSystemTicks' [cc] ..\obj\raw32.o: In function `gfxSleepMicroseconds': [cc] D:\STM32F103 Projects\ugfx_lib\src\gos/raw32.c:403: undefined reference to `gfxMillisecondsToTicks' [cc] D:\STM32F103 Projects\ugfx_lib\src\gos/raw32.c:404: undefined reference to `gfxSystemTicks' [cc] D:\STM32F103 Projects\ugfx_lib\src\gos/raw32.c:408: undefined [cc] D:\STM32F103 Projects\ugfx_lib\src\gos/raw32.c:408: undefined reference to `gfxSystemTicks' [cc] collect2.exe: error: ld returned 1 exit status So I find in raw32.h this remarks * You must also define the following routines in your own code so that timing functions will work... * systemticks_t gfxSystemTicks(void); * systemticks_t gfxMillisecondsToTicks(delaytime_t ms); In main.c I do /* Includes ------------------------------------------------------------------*/ #include "gfx.h" /* Private function prototypes -----------------------------------------------*/ systemticks_t gfxSystemTicks(void); systemticks_t gfxMillisecondsToTicks(delaytime_t ms); /** * @brief Main program. * @param None * @retval None */ int main(void) { coord_t width, height; // Initialize and clear the display gfxInit(); // Get the screen size width = gdispGetWidth(); height = gdispGetHeight(); while(TRUE) { gfxSleepMilliseconds(500); } } systemticks_t gfxSystemTicks(void) { return 0; } systemticks_t gfxMillisecondsToTicks(delaytime_t ms) { return ms; } Everything compiles successfully 8-)
  16. I move gfx.h to ../ugfx_lib directory. It's OK. I place the file board_ILI9325.h in the same directory as gfxconf.h file (in root project directory). It's OK. I add the ILI9325 gdisp driver files to the compile from the master ugfx source (../ugfx_lib/drivers/gdisp/ILI9325) . It's OK. I've updated the last image with this information. It remains to see how to update the board file when using the bare metal port without any underlying OS (RAW32).
  17. Full compiler log GCC HOME: D:\Applications\CooCox\GNU Tools ARM Embedded\4.8 2014q2\bin compile: [mkdir] Created dir: D:\STM32F103 Projects\Test_uGFX\test_ugfx\Debug\bin [mkdir] Created dir: D:\STM32F103 Projects\Test_uGFX\test_ugfx\Debug\obj [cc] 52 total files to be compiled. [cc] arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Wall -ffunction-sections -g -O0 -c -DSTM32F103RB -DSTM32F10X_MD -DUSE_STDPERIPH_DRIVER -D__ASSEMBLY__ "-ID:\STM32F103 Projects\Test_uGFX" "-ID:\STM32F103 Projects\ugfx_lib\src\gdisp\mcufont" "-ID:\STM32F103 Projects\Test_uGFX\cmsis_boot" "-ID:\STM32F103 Projects\ugfx_lib" -ID:\ "-ID:\STM32F103 Projects\ugfx_lib\src" "-ID:\STM32F103 Projects" "-ID:\STM32F103 Projects\ugfx_lib\src\gos" "-ID:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts" "-ID:\STM32F103 Projects\ugfx_lib\src\gdisp" "-ID:\STM32F103 Projects\Test_uGFX\cmsis" "-ID:\STM32F103 Projects\Test_uGFX\stm_lib" "-ID:\STM32F103 Projects\Test_uGFX\stm_lib\inc" "-ID:\STM32F103 Projects\Test_uGFX\gfx_gdisp" '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts\DejaVuSans32.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts\fixed_10x20.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts\LargeNumbers.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts\DejaVuSansBold12_aa.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\mcufont\mf_scaledfont.c"' '"D:\STM32F103 Projects\Test_uGFX\cmsis_boot\system_stm32f10x.c"' '"D:\STM32F103 Projects\Test_uGFX\gfx_gdisp\gdisp_lld_ILI9325.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\image_bmp.c"' '"D:\STM32F103 Projects\Test_uGFX\cmsis_boot\startup\startup_stm32f10x_md.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gos\win32.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gos\chibios.c"' '"D:\STM32F103 Projects\Test_uGFX\stm_lib\src\stm32f10x_gpio.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\image_jpg.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts\UI1.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gos\osx.c"' '"D:\STM32F103 Projects\Test_uGFX\main.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts\DejaVuSans16_aa.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\image_native.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts\fixed_5x8.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts\UI2.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\image_gif.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\mcufont\mf_font.c"' '"D:\STM32F103 Projects\Test_uGFX\stdio\printf.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts\DejaVuSansBold12.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\mcufont\mf_rlefont.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\mcufont\mf_bwfont.c"' '"D:\STM32F103 Projects\Test_uGFX\stm_lib\src\stm32f10x_rcc.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gos\freertos.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts\fixed_7x14.c"' '"D:\STM32F103 Projects\Test_uGFX\stm_lib\src\stm32f10x_exti.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts\DejaVuSans10.c"' '"D:\STM32F103 Projects\Test_uGFX\stm_lib\src\stm32f10x_adc.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\mcufont\mf_encoding.c"' '"D:\STM32F103 Projects\Test_uGFX\stm_lib\src\stm32f10x_usart.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts\DejaVuSans12.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts\DejaVuSans32_aa.c"' '"D:\STM32F103 Projects\Test_uGFX\syscalls\syscalls.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\mcufont\mf_justify.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gos\linux.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts\DejaVuSans16.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\gdisp.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\image_png.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gfx.c"' '"D:\STM32F103 Projects\Test_uGFX\stm_lib\src\misc.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts\DejaVuSans24.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\mcufont\mf_wordwrap.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gos\raw32.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\image.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts\DejaVuSans12_aa.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\fonts\DejaVuSans24_aa.c"' '"D:\STM32F103 Projects\ugfx_lib\src\gdisp\mcufont\mf_kerning.c"' [cc] In file included from D:\STM32F103 Projects\Test_uGFX\gfx_gdisp\gdisp_lld_ILI9325.c:27:0: [cc] D:\STM32F103 Projects\Test_uGFX\gfx_gdisp\board_ILI9325.h: In function 'init_board': [cc] D:\STM32F103 Projects\Test_uGFX\gfx_gdisp\board_ILI9325.h:45:3: warning: implicit declaration of function 'rccEnableAHB' [-Wimplicit-function-declaration] [cc] rccEnableAHB(RCC_AHBENR_FSMCEN, 0); // [cc] ^ [cc] D:\STM32F103 Projects\Test_uGFX\gfx_gdisp\board_ILI9325.h:45:16: error: 'RCC_AHBENR_FSMCEN' undeclared (first use in this function) [cc] rccEnableAHB(RCC_AHBENR_FSMCEN, 0); // [cc] ^ [cc] D:\STM32F103 Projects\Test_uGFX\gfx_gdisp\board_ILI9325.h:45:16: note: each undeclared identifier is reported only once for each function it appears in [cc] D:\STM32F103 Projects\Test_uGFX\gfx_gdisp\board_ILI9325.h:58:3: error: 'FSMC_Bank1' undeclared (first use in this function) [cc] D:\STM32F103 Projects\Test_uGFX\gfx_gdisp\board_ILI9325.h:62:33: error: 'FSMC_BCR1_MWID_0' undeclared (first use in this function) [cc] ^ [cc] FSMC_Bank1->BTCR[FSMC_Bank+1] = (6) | (10 << 8) | (10 << 16); [cc] FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; [cc] D:\STM32F103 Projects\Test_uGFX\gfx_gdisp\board_ILI9325.h:62:52: error: 'FSMC_BCR1_WREN' undeclared (first use in this function) [cc] FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; [cc] D:\STM32F103 Projects\Test_uGFX\gfx_gdisp\board_ILI9325.h:62:69: error: 'FSMC_BCR1_MBKEN' undeclared (first use in this function) [cc] FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; [cc] ^ [cc] D:\STM32F103 Projects\Test_uGFX\gfx_gdisp\gdisp_lld_ILI9325.c: In function 'gdisp_lld_init': [cc] D:\STM32F103 Projects\Test_uGFX\gfx_gdisp\gdisp_lld_ILI9325.c:98:11: warning: variable 'cver' set but not used [-Wunused-but-set-variable] [cc] uint16_t cver; [cc] ^ [cc] ^ [cc] ^ [cc] D:\STM32F103 Projects\Test_uGFX\main.c: In function 'main': [cc] D:\STM32F103 Projects\Test_uGFX\main.c:16:18: warning: variable 'height' set but not used [-Wunused-but-set-variable] [cc] coord_t width, height; [cc] ^ [cc] D:\STM32F103 Projects\Test_uGFX\main.c:16:11: warning: variable 'width' set but not used [-Wunused-but-set-variable] [cc] coord_t width, height; [cc] ^ BUILD FAILED Total time: 11 seconds main.c #include "gfx.h" int main(void) { coord_t width, height; // Initialize and clear the display gfxInit(); // Get the screen size width = gdispGetWidth(); height = gdispGetHeight(); while(TRUE) { gfxSleepMilliseconds(500); } }
  18. Tectu, when configuring GDISP with ILI9325 driver files , I got this errors. File: gdisp_lld_ILI9325.c, Line: 23 #include "drivers/gdisp/ILI9325/gdisp_lld_config.h" I corrected in the following manner: #include "gdisp_lld_config.h" File: board_ILI9325.h, Line: 45 rccEnableAHB(RCC_AHBENR_FSMCEN, 0); Error: gfx_gdisp\board_ILI9325.h:45:16: error: 'RCC_AHBENR_FSMCEN' undeclared (first use in this function) File: board_ILI9325.h, Line: 58 FSMC_Bank1->BTCR[FSMC_Bank+1] = (6) | (10 << 8) | (10 << 16); Error: gfx_gdisp\board_ILI9325.h:58:20: error: 'FSMC_Bank' undeclared (first use in this function) File: board_ILI9325.h, Line: 62 FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; Error: gfx_gdisp\board_ILI9325.h:62:69: error: 'FSMC_BCR1_MBKEN' undeclared (first use in this function)
  19. OK No worries it is with pleasure 8-) Christian.
  20. Tectu, Yes, it is exactly that. This wil be a tutorial-like guide to use ugfx with coocox coIDE. I will now proceed Step 2.
  21. Hello, I'm really new in Coocox CoIDE & uGFX library. In this topic, I propose to build coIDE project with uGFX library V2.1 for STM32F103RB board. Excuse me for my poor english, I'm french. Architecture - OS Abstractions: BareBone - Chip: STM32F103RB (Cortex-M3 core) - LCD controller: ILI9325 - Touchscreen controller: ADS7843 - Audio controller: ADC Step 1: Default coIDE project coIDE project basic components : Common - C Library: Implement the minimal functionality required to allow newlib to link - Retarget printf: Implementation of printf(), sprintf() to reduce memory footprint - CMSIS core: CMSIS core for Cortex M3 V3.01 Boot - CMSIS Boot: CMSIS boot for STM32 Peripheral - RCC: Reset and clock control driver. - GPIO: General purpose I/O ports driver. - EXTI: External interrupt and event controller driver. - ADC: Analog to digital converter driver. - USART: Universal synchronous asynchronous receiver transmitter driver - MISC: Miscellaneous driver. I use ARM GCC as the compiler. See CoIDE Compiler Setting. Step 2: Integrate µGFX with coIDE Directories CoIDE compile settings Set directory of uGFX library in Includepaths. For this example it is ../ugfx_lib Copy gfx.h & gfxconf.example.h from ugfx_lib (directory of uGFX library) to Test_uGFX (directory of coIDE Project). In Test_uGFX, rename gfxconf.example.h to gfxconf.h I use bare metal without any underlying OS, I set GFX_USE_OS_RAW32 option to TRUE in gfxconf.h You must get this Step 3: Using GDISP Enable the entire GDISP module in gfxconf.h (set GFX_USE_GDISP to TRUE). Copy display config file uGfx library\boards\addons\gdisp\board_ILI9325_hy_stm32_100p.h to board_ILI9325.h in root project directory. Todo .......
×
×
  • Create New...