TomCat
Members-
Posts
6 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
dear @inmarket I`v always been unsuccessful with libraries and also my project has a lot of things except of LCD and if I use those files, I think I will have many problems for debugging my project.I want every thing to be clear and that files and libraries make my project messy. when i glance at those libraries every time I get confused.
-
Hi @ASergej thank you for that.I already seen your code in the first topic and it was good.you had a problem at the end of that topic and you said you solve it yourself.would you please tell me what that problem was?
-
you did a good job.I`m not sure I have time to spend on µGFX library, I write direct code.my problem is that the SPI works well, but when I configure the ili9341 for rgb565 and then using LTDC, the LCD doesnt work well and i dont know whats the problem.here is the code for initializing ili9341: void lcd_initialization(void){ lcd_cmd(0x28); //Display Off lcd_cmd(0x11); //Exit Sleep,Start internal OSC delay_ds(120000); //delay for 120 miliseconds lcd_cmd(0x00B6); //Display Function Control lcd_data(0x000A); lcd_data(0x0A2); lcd_data(0x27); lcd_data(0x4); lcd_cmd(0x00B4); //Display Inversion Control lcd_data(0x004); lcd_cmd(0xB5); //Blanking Porch Control lcd_data(0x4); lcd_data(0x2); lcd_data(0xa); lcd_data(0x14); lcd_cmd(0xCF); //Power control B lcd_data(0x0); lcd_data(0x81); lcd_data(0xc0); lcd_cmd(0xEF); lcd_data(0x3); lcd_data(0x80); lcd_data(0x2); lcd_cmd(0xED); // Power on sequence control lcd_data(0x64); lcd_data(0x03); lcd_data(0x12); lcd_data(0x81); lcd_cmd(0xE8); // Driver timing control A lcd_data(0x85); lcd_data(0x01); lcd_data(0x798); lcd_cmd(0xCB); // Power control A lcd_data(0x39); lcd_data(0x2c); lcd_data(0x0); lcd_data(0x34); lcd_data(0x2); lcd_cmd(0x00F7); // Pump ratio control lcd_data(0x0020); lcd_cmd(0x00CA); lcd_data(0x0083); lcd_data(0x0002); lcd_data(0x0000); lcd_cmd(0x00EA); // Driver timing control B lcd_data(0x0000); lcd_data(0x0000); lcd_cmd(0x00C0); //Power Control 1 lcd_data(0x005); lcd_cmd(0x00C1); //Power Control 2 lcd_data(0x0011); lcd_cmd(0x00C5); //VCOM Control 1 lcd_data(0x0045); lcd_data(0x0045); lcd_cmd(0x0036); //Memory Access Control lcd_data(0x0008); lcd_cmd(0x00B1); //Frame Rate Control (In Normal Mode/Full Colors) lcd_data(0x0000); lcd_data(0x001b); lcd_cmd(0x00C7); //VCOM Control 2 lcd_data(0x00A2); lcd_cmd(0x00F2); // Enable 3G lcd_data(0x000); lcd_cmd(0x26); //Gamma Set lcd_data(0x1); lcd_cmd(0x00E0); //Positive Gamma Correction lcd_data(0x001F); lcd_data(0x001a); lcd_data(0x0018); lcd_data(0x000a); lcd_data(0x000f); lcd_data(0x0006); lcd_data(0x0045); lcd_data(0x0087); lcd_data(0x0032); lcd_data(0x000a); lcd_data(0x0007); lcd_data(0x002); lcd_data(0x001f); lcd_data(0x0007); lcd_data(0x0005); lcd_data(0x0000); lcd_cmd(0x00E1); //Negative Gamma Correction lcd_data(0x0000); lcd_data(0x0025); lcd_data(0x0027); lcd_data(0x0005); lcd_data(0x0010); lcd_data(0x0009); lcd_data(0x003a); lcd_data(0x0078); lcd_data(0x004d); lcd_data(0x0005); lcd_data(0x0018); lcd_data(0x000d); lcd_data(0x0038); lcd_data(0x003a); lcd_data(0x001F); delay_ds(120000); lcd_cmd(0x002A); //Column Address Set lcd_data(0x0); lcd_data(0x0); lcd_data(0x0000); lcd_data(0x00EF); lcd_cmd(0x002B); //Page Address Set lcd_data(0x0000); lcd_data(0x0000); lcd_data(0x0001); lcd_data(0x003F); lcd_cmd(0x003A); //COLMOD: Pixel Format Set lcd_data(0x0055); lcd_cmd(0xF6); //Interface Control lcd_data(0x1); lcd_data(0x30); lcd_data(0x0); lcd_cmd(0xB7); //Entry Mode Set lcd_data(0x7); lcd_cmd(0xB0); //RGB Interface Signal Control lcd_data(0x40); lcd_cmd(0x0029); //Display ON lcd_cmd(0x002C); //Memory Write } and below is for stm32f429 LTDC: #include "stm32f4xx.h" #include "initialization.h" #include "White-Tiger-vertical.h" #include "CAR.h" #define LCD_WIDTH 320 //Vadr #define LCD_HEIGHT 240 //Hadr #define HFP 10 #define HSYNC 10 #define HBP 20 #define VFP 4 #define VSYNC 2 #define VBP 2 #define ACTIVE_W (HSYNC + LCD_WIDTH + HBP - 1) #define ACTIVE_H (VSYNC + LCD_HEIGHT + VBP - 1) #define TOTAL_WIDTH (HSYNC + HBP + LCD_WIDTH + HFP-1) //horizontal period #define TOTAL_HEIGHT (VSYNC + VBP + LCD_HEIGHT + VFP-1) //vertical period #define t2start TIM2->CR1|= 0x0001 // Enable Counting int delay_ds(int us){ int value; value=((us*90)-1); TIM2->ARR=value; //giving value for counting t2start; // Enable Counting while(TIM2->CR1&1); us=0; value=0; return(0);} int main(void){ int j,i,x=0; RCC->APB2RSTR=0; RCC->AHB1ENR=0x1ff; RCC->APB1ENR|=0xb; //CONNECTS clock to TIM2 and TIM3 and TIM5 RCC->APB2ENR|=1<<20; //connect clock to SPI5 RCC->APB2ENR|=1<<26; //enabled LTDC clock RCC->PLLSAICFGR|=0x102<<6; //PLLSAIN=254.should be written only if PLLSAI is disabled RCC->PLLSAICFGR|=5<<28; //PLLSAIR=5.should be written only if PLLSAI is disabled RCC->DCKCFGR|=2<<16; //SETS PLLCDCLK(THE DIVIDER AFTER PLLSAIR) //LTDC CLOCK IS SET TO 6.45 MHz RCC->CR|=1<<28; //ENABLE PLLSAI while(!(RCC->CR & RCC_CR_PLLSAIRDY)); //WAIT FOR PLLSAI TO LOCK TIM2->DIER|= 0x0001; //DMA/IRQ Enable Register - enable IRQ on update TIM2->CR1|=1<<3; //Counter stops counting at the next update event (clearing the bit CEN) //SPI5 CONFIGURATION SPI5->CR1=0; SPI5->CR1|=1<<3; //BAUDRATE: APB2 WORKS WITH 90MHz.SO PRESCALER=4 AND BAUDRATE=22500000 SPI5->CR1|=1<<2; //SPI1 AS MASTER SPI5->CR1|=1<<15; //1-line bidirectional data mode selected SPI5->CR1|=1<<14; //Output enabled (transmit-only mode) SPI5->CR2|=1<<2; //HARDWARE NSS //SPI5 CONFIGURATION GPIOC->MODER|=1<<4; GPIOD->MODER|=1<<26; GPIOF->MODER|=0x2a<<14; GPIOF->AFR[0]=0x50000000; GPIOF->AFR[1]=0x55; lcd_initialization(); //PIN CONFIGURATION FOR LCD //All GPIOs have to be configured in very high-speed mode GPIOA->MODER=0x2802280; GPIOB->MODER=0xaa000a; GPIOC->MODER|=0xa000; GPIOD->MODER|=0x80; GPIOF->MODER|=0x200000; GPIOG->MODER=0x2a0a000; GPIOA->AFR[0]=0xe0ee000; GPIOA->AFR[1]=0xee000; GPIOB->AFR[0]=0x99; //GPIOB->AFR[0]=0xee; GPIOB->AFR[1]=0xeeee; GPIOC->AFR[0]=0xee000000; GPIOD->AFR[0]=0xe000; GPIOF->AFR[1]|=0xe00; GPIOG->AFR[0]=0xee000000; GPIOG->AFR[1]=0x9e900; //GPIOG->AFR[1]=0xeee00; GPIOA->OSPEEDR=0xffffffff; GPIOB->OSPEEDR=0xffffffff; GPIOC->OSPEEDR=0xffffffff; GPIOD->OSPEEDR=0xffffffff; GPIOF->OSPEEDR=0xffffffff; GPIOG->OSPEEDR=0xffffffff; //PIN CONFIGURATION FOR LCD LTDC->SSCR=((HSYNC-1)<<16)|(VSYNC-1); //Synchronization Size Configuration LTDC->BPCR=((HBP-1)<<16)|(VBP-1); //Back Porch Configuration LTDC->AWCR=(ACTIVE_W<<16)|(ACTIVE_H); //Active Width Configuration LTDC->TWCR=(TOTAL_WIDTH<<16)|(TOTAL_HEIGHT); //Total Width Configuration LTDC_Layer1->WHPCR=HBP|((HBP+LCD_WIDTH-1)<<16); //Window Horizontal Position Configuration LTDC_Layer1->WVPCR=VBP|((VBP+LCD_HEIGHT-1)<<16); //Window Vertical Position Configuration LTDC_Layer1->PFCR=2; //Pixel Format Configuration LTDC_Layer1->CFBAR=0x10; LTDC_Layer1->CFBLR=((LCD_WIDTH*10)<<16)|((LCD_WIDTH*10)+3);//Color Frame Buffer Length LTDC_Layer1->CR=LTDC_LxCR_LEN; //Enable Layer LTDC->SRCR=LTDC_SRCR_IMR; //Immediate Reload //LTDC->GCR=LTDC_GCR_PCPOL; //active high pcpol / LTDC->GCR|=LTDC_GCR_LTDCEN; //Enable LTDC / while(1)LTDC->BCCR = 0xff; //display blue background; while(1){ if(x>76799)x=0; x++; } } anyway thanks for you replied.
-
Hi.I`m working on a stm32f429 discovery and have problem with the LCD.I`v done any thing for SPI interface with iLi9341 and that was successful.but I wanna configure iLi9341 with SPI to send display data through st`s LTDC peripheral and thats my big problem.can anyone help me?