Hi, In my project I'm using LPC2378. I Connect display to the IO ports. (DLC0283) This display use a tft driver ILI9341
It has 8 bit data - I Connect it to P1.24-31 It has WR bit and CS bit. The display data is arranged in 16bit per pixel.
To fill a full screen with data (To clear the screen) (The color data - 16 bits - lower and upper bytes are not the same)
I create 2 integer that hold the upper & lower part of color (col_M32 & col_L32)
1. Set the frame addr (not shown here) 2. Set the CS bit to 0 3. Write the Most 8 bit of color 4. Set WR bit to 0 - then 1 5. Write the Least 8 bit of color 6. Set WR bit to 0 - then 1 7. Repeat lines 3-6 320*240 times. 8. Set the CS bit to 0
ILI_CS_0; for (row=0;row<TFT_Y;row++){ for (col=0;col<TFT_X;col++){ ILI_DAT_CLR=0xff000000; ILI_DAT_SET=col_M32; ILI_WR_0; ILI_WR_1; ILI_DAT_CLR=0xff000000; ILI_DAT_SET=col_L32; ILI_WR_0; ILI_WR_1; } } ILI_CS_1;
The problem is that it works perfect - but it took about 1 second to finish and the effect of clear the screen is very bad. In perfect world - the driver should have a command to do that - but thats life.
So - I need this code to run the fastest as it can.
When I look at the assembly code of the above code It seems to me that there are many assemblly commands that can be removed. But I'm not good in assembly - I think that the above code can be created with less commands in assembly that I can insert in my code.
Here is the assembly part of the above code :
467: ILI_CS_0; 0x0003C908 E3A00701 MOV R0,#0x00040000 0x0003C90C E3A0190A MOV R1,#0x00028000 0x0003C910 E281120E ADD R1,R1,#WDMOD(0xE0000000) 0x0003C914 E581001C STR R0,[R1,#0x001C] 468: for (row=0;row<TFT_Y;row++){ 0x0003C918 E3A05000 MOV R5,#last_energy_valsH(0x00000000) 0x0003C91C EA000019 B 0x0003C988 469: for (col=0;col<TFT_X;col++){ 470: 0x0003C920 E3A04000 MOV R4,#last_energy_valsH(0x00000000) 0x0003C924 EA000013 B 0x0003C978 471: ILI_DAT_CLR=0xff000000; 0x0003C928 E3A004FF MOV R0,#0xFF000000 0x0003C92C E3A0190A MOV R1,#0x00028000 0x0003C930 E281120E ADD R1,R1,#WDMOD(0xE0000000) 0x0003C934 E581001C STR R0,[R1,#0x001C] 472: ILI_DAT_SET=col_M32; 0x0003C938 E59F006C LDR R0,[PC,#0x006C] 0x0003C93C E5900000 LDR R0,[R0] 0x0003C940 E5810014 STR R0,[R1,#0x0014] 473: ILI_WR_0; 0x0003C944 E3A00702 MOV R0,#0x00080000 0x0003C948 E581001C STR R0,[R1,#0x001C] 474: ILI_WR_1; 475: 0x0003C94C E5810014 STR R0,[R1,#0x0014] 476: ILI_DAT_CLR=0xff000000; 0x0003C950 E3A004FF MOV R0,#0xFF000000 0x0003C954 E581001C STR R0,[R1,#0x001C] 477: ILI_DAT_SET=col_L32; 0x0003C958 E59F0048 LDR R0,[PC,#0x0048] 0x0003C95C E5900000 LDR R0,[R0] 0x0003C960 E5810014 STR R0,[R1,#0x0014] 478: ILI_WR_0; 0x0003C964 E3A00702 MOV R0,#0x00080000 0x0003C968 E581001C STR R0,[R1,#0x001C] 479: ILI_WR_1; 480: 481: } 483: } 0x0003C96C E5810014 STR R0,[R1,#0x0014] 0x0003C970 E2840001 ADD R0,R4,#0x00000001 0x0003C974 E3C04801 BIC R4,R0,#0x00010000 0x0003C978 E3540D05 CMP R4,#0x00000140 0x0003C97C BAFFFFE9 BLT 0x0003C928 0x0003C980 E2850001 ADD R0,R5,#0x00000001 0x0003C984 E3C05801 BIC R5,R0,#0x00010000 0x0003C988 E35500F0 CMP R5,#0x000000F0 0x0003C98C BAFFFFE3 BLT 0x0003C920 484: ILI_CS_1; 485: 486: #endif 0x0003C990 E3A00701 MOV R0,#0x00040000 0x0003C994 E3A0190A MOV R1,#0x00028000 0x0003C998 E281120E ADD R1,R1,#WDMOD(0xE0000000) 0x0003C99C E5810014 STR R0,[R1,#0x0014] 487: }
Any help? Thanks, Doron
Nice. How much did you manage to reduce the assembler output of the inner loop?
Hi Per, The final code reduced to 6 lines - as you recomended - with pointer. The WR bit is on the same port
*io_port=V_M_1; *io_port=V_M_0; *io_port=V_M_1; *io_port=V_L_1; *io_port=V_L_0; *io_port=V_L_1;
The result is so fast. Thanks, Doron