Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

TFT with ILI9341 controller
Goto page Previous  1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Thu Jan 08, 2015 3:19 am    Post subject: assembler and Bascom Reply with quote

Paulo

Here some links: in German, but Google Translate is your friend..

Assembler and Bascom

http://rn-wissen.de/wiki/index.php/Assembler_Einf%C3%BChrung_f%C3%BCr_Bascom-User

Bascom and libraries

And found also some good information about building libraries
http://rn-wissen.de/wiki/index.php/Bascom_Libraries

Bascom-inside
http://rn-wissen.de/wiki/index.php/Bascom_Inside

I am also very carefull about using registers in assembler in Bascom.

Have fun
Ben Zijlstra[/url]


Last edited by bzijlstra on Thu Jan 08, 2015 2:41 pm; edited 2 times in total
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Thu Jan 08, 2015 9:18 am    Post subject: Re: assembler and Bascom Reply with quote

bzijlstra wrote:
http://rn-wissen.de/wiki/index.php/Assembler_Einführung_für_Bascom-User

Ben,

edit your link, it does not work, other by copy and paste.


Paulo,

Asm in Bascom is quite easy, one rule is: the compiler does not keep variables in processor registers, except a few, these are:

R4, R5 (frame pointer)
R6 (flags)
R8, R9 (data pointer)
R28, R29: Y-pointer (stack pointer)

Beside R8, R9 I do strongly recommend, not to touch them.
R8, R9 is the pointer for the Read() command and sometimes it comes handy to alter it, to do random reads.

Bascom always exits clean after an command, means: all values it worked with, are stored back into the appropriate memory cells, the processors status register SREG can be considered as void.
So you are free to alter and destroy any register, including SREG, excluded the ones mentioned above.
Well, one exception also here, if you alter the I-flag of SREG, you enable/disable global interrupts, you need to take care about that.

The difference is an interrupt, as an interrupt can occur anytime, so it is not guaranteed that an Bascom command will be able to finish.
In fact, very likely an interrupt will happen within a Bascom command, which itself is built out of a bunch of asm commands.
At this point the values kept in the processor registers need to be preserved, this is then the reason, why an interrupt needs to save all registers, it possibly alters.

But in normal code, you can forget all that push/pop/SREG stuff, other you need to do it for some reason for your own code.
Back to top
View user's profile
aphawk

Bascom Member



Joined: 23 Jan 2010
Posts: 168
Location: Brazil

brazil.gif
PostPosted: Thu Jan 08, 2015 12:14 pm    Post subject: Reply with quote

Mws and Ben,

Wow, this will help me a lot in some codes ! Thanks for the links and this information about the registers I really need to maintain.

I will rewrote the codes and post here again !

Paulo
Back to top
View user's profile
aphawk

Bascom Member



Joined: 23 Jan 2010
Posts: 168
Location: Brazil

brazil.gif
PostPosted: Sat Jan 10, 2015 12:37 am    Post subject: Reply with quote

This is the new code with the MWS observations. I made the subroutine Lcd_set_window() in ASM too, because it is used in others primitives in Circle Draw, and now is very faster. Just replace then in the original ILI9341_Routines.inc .
This mods shows that even with a little knowledge in ASM ( like me ) everyone can obtain very good results mixing Bascom with some Asm.

Now the display is very faster, and with the little cost is a very good alternative.

Code:

'*******************************************************************************
'  Clear Display
'*******************************************************************************
 Sub Lcd_clear(byval Color As Word)

#if Lcd_mode = 1
   Call Lcd_set_window(0 , 0 , 239 , 319)
#else
   Call Lcd_set_window(0 , 0 , 319 , 239)
#endif

   Lcd_cs = 0
   Lcd_dc = 1
   $asm
      LD XL, Y+0
      LD XH, Y+1
      ld r18,x+
      LD R17,X
      LDi R26,1                                            
      LDI R19,241
      LDi R27,1                                            
      LDI R20,81

      Spi_denovo:
      Out Spdr , R17

      Spi_wait:
      sbis spsr,spif
      rjmp spi_wait
      Out Spdr , R18

      Spi_wait1:
      sbis spsr,spif
      rjmp spi_wait1
      Out Spdr , R17

      Spi_wait2:
      sbis spsr,spif
      rjmp spi_wait2
      Out Spdr , R18

      Spi_wait3:
      sbis spsr,spif
      rjmp spi_wait3
      Out Spdr , R17

      Spi_wait4:
      sbis spsr,spif
      rjmp spi_wait4
      Out Spdr , R18

      Spi_wait5:
      sbis spsr,spif
      rjmp spi_wait5
      Out Spdr , R17

      Spi_wait6:
      sbis spsr,spif
      rjmp spi_wait6
      Out Spdr , R18

      Spi_wait7:
      sbis spsr,spif
      rjmp spi_wait7

      inc r27
      cpSE r27,R20
      RJMP SPI_DENOVO

      LDI R27,1
      INC R26
      CPSE R26,R19
      RJMP SPI_DENOVO

   $end Asm
   Lcd_cs = 1
End Sub
 


Code:

'*******************************************************************************
' send Color Data
'*******************************************************************************
Sub Lcd_write_color(byval Color As Word)
   Lcd_cs = 0
   Lcd_dc = 1
   $asm
      ldd r26,y
      ldd r27,y+1
      ld r18,x+
      ld r17,x
      Out Spdr , R17
      Spi_waitwco1:
      sbis spsr,spif
      rjmp spi_waitwco1
      Out Spdr , R18
      Spi_waitwco2:
      sbis spsr,spif
      rjmp spi_waitwco2
   $end Asm
   Lcd_cs = 1
End Sub
 


Code:

'*******************************************************************************
' send Command
'*******************************************************************************
Sub Lcd_write_command(byval Command As Byte)
   Lcd_cs = 0
   Lcd_dc = 0
   $asm
      ldd r26,y
      ldd r27,y+1
      ld r18,x
      Out Spdr , R18
      Spi_waitwc:
      sbis spsr,spif
      rjmp spi_waitwc
   $end Asm
   Lcd_cs = 1
End Sub
 


Code:

'*******************************************************************************
'  send Data
'*******************************************************************************
Sub Lcd_write_data(byval Da_ta As Byte)
   Lcd_cs = 0
   Lcd_dc = 1
   $asm
      ldd r26,y
      ldd r27,y+1
      ld r18,x
      Out Spdr , R18
      Spi_waitwd:
      sbis spsr,spif
      rjmp spi_waitwd
   $end Asm
   Lcd_cs = 1
End Sub
 


Code:

'*******************************************************************************
'  Set Windows
'*******************************************************************************
Sub Lcd_set_window(byval Xs As Word , Byval Ys As Word , Byval Xe As Word , Byval Ye As Word)
    Lcd_cs = 0
    Lcd_dc = 0
   $asm
      ldi r18,$2A
      Out Spdr , R18
      Spi_waitlsw1:
      sbis spsr,spif
      rjmp spi_waitlsw1
   $end Asm
'   Lcd_cs = 1
'   Lcd_cs = 0
   Lcd_dc = 1
   $asm
      ldd r26,y+6
      ldd r27,y+7
      ld r18,x+
      ld r17,x
      Out Spdr , R17
      Spi_waitlsw2:
      sbis spsr,spif
      rjmp spi_waitlsw2
      Out Spdr , R18
      Spi_waitlsw3:
      sbis spsr,spif
      rjmp spi_waitlsw3
      ldd r26,y+2
      ldd r27,y+3
      ld r18,x+
      ld r17,x
      Out Spdr , R17
      Spi_waitlsw4:
      sbis spsr,spif
      rjmp spi_waitlsw4
      Out Spdr , R18
      Spi_waitlsw5:
      sbis spsr,spif
      rjmp spi_waitlsw5
   $end Asm
'    Lcd_cs = 1
'    Lcd_cs = 0
    Lcd_dc = 0
   $asm
      ldi r18,$2b
      Out Spdr , R18
      Spi_waitlsw6:
      sbis spsr,spif
      rjmp spi_waitlsw6
   $end Asm
'   Lcd_cs = 1
'   Lcd_cs = 0
   Lcd_dc = 1
   $asm
      ldd r26,y+4
      ldd r27,y+5
      ld r18,x+
      ld r17,x
      Out Spdr , R17
      Spi_waitlsw7:
      sbis spsr,spif
      rjmp spi_waitlsw7
      Out Spdr , R18
      Spi_waitlsw8:
      sbis spsr,spif
      rjmp spi_waitlsw8
      ldd r26,y+0
      ldd r27,y+1
      ld r18,x+
      ld r17,x
      Out Spdr , R17
      Spi_waitlsw9:
      sbis spsr,spif
      rjmp spi_waitlsw9
      Out Spdr , R18
      Spi_waitlsw10:
      sbis spsr,spif
      rjmp spi_waitlsw10
   $end Asm
'   Lcd_cs = 1
'   Lcd_cs = 0
   Lcd_dc = 0
   $asm
      ldi r18,$2c
      Out Spdr , R18
      Spi_waitlsw11:
      sbis spsr,spif
      rjmp spi_waitlsw11
   $end Asm
   Lcd_cs = 1
End Sub
 


Paulo
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Sat Jan 10, 2015 7:59 am    Post subject: ASM... Reply with quote

Looks a lot like Bascom-ASM now 😊

Perhaps you can put some comments in the code to show what the program is doing.

Thanks for sharing and I will be waiting for any comments of MWS.

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Sat Jan 10, 2015 10:54 pm    Post subject: Re: ASM... Reply with quote

bzijlstra wrote:
Thanks for sharing and I will be waiting for any comments of MWS.

Why me? I'm not the guilty one. LOL

From the POV of pretty code, I would exchange that tapeworm
Code:
Spi_waitn:
sbis spsr,spif
rjmp spi_waitn
Out Spdr , R17...R18

against a loop. What is done there, is called code-unrolling, which can be done for the purpose of speed, but I don't see the purpose here, as there are waits for SPI anyway.

Some "peanuts":
Code:
LDI R26,1
LDI R19,241
'...
INC R26
CPSE R26,R19
RJMP SPI_DENOVO

the loop part costs 3 cycles for a miss and jump.
Code:
LDI R26,240
'...
DEC R26
BRNE SPI_DENOVO

is one cycle and one register less.
Some design knick-knack:
Code:
LD R18, X+
LD R17, X

As already said, for word values I'd use register pairs, starting with even for low byte, and odd for high byte, so my choice would be:
Code:
LD R18, X+
LD R19, X

Of course adapted to the complete code.

Otherwise I'm quite satisfied with aphawk.
Back to top
View user's profile
aphawk

Bascom Member



Joined: 23 Jan 2010
Posts: 168
Location: Brazil

brazil.gif
PostPosted: Sun Jan 11, 2015 2:19 am    Post subject: Reply with quote

Kkkkkk, I'm the only guilty for this code !!!

MWS, I know that the code can be otimized , but my intent has already been achieved. The speed was faster, and can make graphics very faster than before. And the total size has decreased by 2% , and for an Arduino Uno this means about 640 Bytes gained to my own program. Really, it is a worm code, but works .....

I'm learning with your comments, and be sure that I will use then in my next code.

Your comments will be always welcome !


Ben, I only write the same routines that exists in Bascom code, but I can comment then for a better understanding. I'll edit the post tomorrow. And about sharing code, you show to all of us that sharing code is very necessary to help others members. And I always share my codes here in Brasil, just to bring more peoples to Bascom. You can see here :
http://forum.clubedohardware.com.br/topic/937085-tutorial-de-projetos-com-avr-design-programação-em-basic-e-simulação-no-proteus/

About the SPI code, I read the Atmel examples, and use in the same way. Because SPI clock is the CPU clock /2 , to send 8 bits costs 16 clock cicles, I could made a small delay, but I prefer to check if the byte has been sent verifying the SPI Status bit. This works always, with all speeds of SPI clock.

The code was so simply because we don't use interrupts, and don't need to receive any byte from SPI.

Thanks again, Ben and MWS !

Paulo
Back to top
View user's profile
aphawk

Bascom Member



Joined: 23 Jan 2010
Posts: 168
Location: Brazil

brazil.gif
PostPosted: Mon Jan 12, 2015 4:00 am    Post subject: Reply with quote

I rewrote another primitive subroutine in Asm : Lcd_set_pixel() , that is called for all the others to draw lines, circles, text, and to plot a single point in display.

Again, the speed has increased for all operations. The difference from the original routines and the new ASM routines is very satisfactory !

This is the original code :

Code:

'*******************************************************************************
'Set Pixel
'*******************************************************************************
Sub Lcd_set_pixel(byval X As Word , Byval Y As Word , Byval Color As Word)
   Local Xx As Word , Yy As Word
   Xx = X + 1
   Yy = Y + 1
   Call Lcd_set_window(x , Y , Xx , Yy)
   Call Lcd_write_color(color)
End Sub
 


I see that this function works creating a new window with the X,Y initial coordinates increased by one to make the final coordinates.
The original code uses two local variables that reflects the original X,Y increased by one.
This two operations and the subsequents CALL can be replaced with an ASM code that will be faster.
As X and Y are in stack, I use then , and with the ASM instruction ADIW reg,1 I can made the sum with only two clock cicles.
The problem is that this instruction only works for register pairs R24,R26,R28 and R30.
Then, I use the pair R24/R25 , and this makes the function smaller.

This is the new Lcd_set_pixel(), using the correct register pair as MWS mentioned ! Very Happy

Code:

'*******************************************************************************
'Set Pixel
'*******************************************************************************
Sub Lcd_set_pixel(byval X As Word , Byval Y As Word , Byval Color As Word)
    Lcd_cs = 0
    Lcd_dc = 0
   $asm
      ldi r18,$2A                   ' command to set the horizontal coordinate
      Out Spdr , R18
      Spi_waitlsw1a:
      sbis spsr,spif
      rjmp spi_waitlsw1a
   $end Asm
   Lcd_dc = 1
   $asm
      ldd r26,y+4                 ' got the original X value in word ( high and low byte )
      ldd r27,y+5
      ld r24,x+
      ld r25,x
      Out Spdr , R25             ' sending the first byte

      Spi_waitlsw2a:
      sbis spsr,spif                ' check to see if the byte has send out
      rjmp spi_waitlsw2a
      Out Spdr , R24             ' now send the second byte

      Spi_waitlsw3a:
      sbis spsr,spif
      rjmp spi_waitlsw3a
      adiw r24,1                   ' this wil create X+1 quicly !
      Out Spdr , R25             ' now sending the X+1

      Spi_waitlsw4a:
      sbis spsr,spif
      rjmp spi_waitlsw4a
      Out Spdr , R24

      Spi_waitlsw5a:
      sbis spsr,spif
      rjmp spi_waitlsw5a
   $end Asm
    Lcd_dc = 0
   $asm
      ldi r18,$2b                   ' now command to set the vertical coordinate
      Out Spdr , R18

      Spi_waitlsw6a:
      sbis spsr,spif
      rjmp spi_waitlsw6a
   $end Asm
   Lcd_dc = 1
   $asm
      ldd r26,y+2                 ' got the Y value from stack
      ldd r27,y+3                 ' and make the same as above....
      ld r24,x+
      ld r25,x
      Out Spdr , R25

      Spi_waitlsw7a:
      sbis spsr,spif
      rjmp spi_waitlsw7a
      Out Spdr , R24

      Spi_waitlsw8a:
      sbis spsr,spif
      rjmp spi_waitlsw8a
      adiw r24,1                  ' Y+1
      Out Spdr , R25

      Spi_waitlsw9a:
      sbis spsr,spif
      rjmp spi_waitlsw9a
      Out Spdr , R24

      Spi_waitlsw10a:
      sbis spsr,spif
      rjmp spi_waitlsw10a
   $end Asm
   Lcd_dc = 0
   $asm
      ldi r18,$2c                       ' coordinates are set, then finalize
      Out Spdr , R18

      Spi_waitlsw11a:
      sbis spsr,spif
      rjmp spi_waitlsw11a
   $end Asm
   Lcd_dc = 1
   $asm
      ldd r26,y                         ' now got the color value from stack
      ldd r27,y+1                     ' to set the pixel's color.
      ld r18,x+
      ld r19,x
      Out Spdr , R19

      Spi_waitwco1a:
      sbis spsr,spif
      rjmp spi_waitwco1a
      Out Spdr , R18

      Spi_waitwco2a:
      sbis spsr,spif
      rjmp spi_waitwco2a
   $end Asm
   Lcd_cs = 1
End Sub
 


Paulo


Last edited by aphawk on Mon Jan 12, 2015 10:48 am; edited 1 time in total
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Mon Jan 12, 2015 6:14 am    Post subject: text routine Reply with quote

If you check the code of six1 about text you will see he makes a small window the size of the character and with one flow let the character fill the window. No set x/y just let if flow. Haven't checked your text routine, perhaps you are already using it.

Nice to see the fast routines. Got also this display and will have a try.

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
aphawk

Bascom Member



Joined: 23 Jan 2010
Posts: 168
Location: Brazil

brazil.gif
PostPosted: Mon Jan 12, 2015 11:21 am    Post subject: Reply with quote

Ben,

I don't rewrite the original text subroutine because there are many Bascom commands and many searchs for tables... I will have much trouble to make all this in ASM, and the text write speed in display was good enough to me.

The text code calls Lcd_set_pixel() 8 times for each character ( maybe less if there is transparent pixels in the character ), and to really make significant speed improvements, all the Bascom code must be rewrite in ASM. At moment, this is much trouble to me ! Embarassed
Maybe in the next time when I feel myself more experienced with ASM !

My objective was make the graphic plot quickly because each battery discharge will use almost all the screen area, about 300 single X,Y plots, and with original code it takes seconds to clear the screen and many seconds to plot all, giving an false idea that Bascom is slow. And to make this quickly, all others primitive subroutines gain more speed too.

Give a try for this display, today I found it in Ebay about US$ 4,30 already with shipping costs ! Very attractive for a 2.2" 262K colors display with 200 x 320 pixels and an SD card to keep the data! I bought two more....

Paulo
Back to top
View user's profile
Hkipnik

Bascom Member



Joined: 03 May 2010
Posts: 20

PostPosted: Mon Jan 12, 2015 7:19 pm    Post subject: Reply with quote

Hello,

here is a newer and faster Program.
Back to top
View user's profile
aphawk

Bascom Member



Joined: 23 Jan 2010
Posts: 168
Location: Brazil

brazil.gif
PostPosted: Mon Jan 12, 2015 11:04 pm    Post subject: Reply with quote

Hkipnik,

Thanks for these new routines, I will try then today !

Paulo
Back to top
View user's profile
aphawk

Bascom Member



Joined: 23 Jan 2010
Posts: 168
Location: Brazil

brazil.gif
PostPosted: Mon Jan 12, 2015 11:05 pm    Post subject: Reply with quote

Hkipnik,

Really is faster than the original code. But my ASM versions are faster than the new code. Then I made another "mix" , and replace your Lcd_set_window(), Lcd_write_color(), Lcd_write_command(), Lcd_write_data() with my ASM code, and all is even faster now.

Your new Lcd_text() with the new Bold option is very good, and Lcd_box() now is faster than original, thanks a lot !

One curiosity : you made the Lcd_clear() in ASM too, but I see that my original ASM code for this function is a little faster ... then I replaced by mine, too. But don't know why....

This little display are surprising me even more !

Paulo

One video is better than 1000 words, right ? I make with my Iphone, but can show the display working.

http://youtu.be/bebcHXr0N_c
Back to top
View user's profile
yanuarm

Bascom Member



Joined: 07 Feb 2015
Posts: 1
Location: Batang

indonesia.gif
PostPosted: Sat Feb 07, 2015 12:16 pm    Post subject: Reply with quote

i have problem with my lcd tft, this is my code

Code:

'*******************************************************************************
' SD Card CS --> portb.0
'       Miso --> portb.3
'       Mosi --> portb.2
'        SCK --> portb.1
'Display
'         CS --> porta.0
'         DC --> porta.2
'      reset --> porta.1
'        SCK --> portb.1
'  Mosi(SDI) --> portb.2
'        LED --> 3,3V
' with Level-Shifter the Display works with 3,3V level
'*******************************************************************************

$regfile = "m128def.dat"
$crystal = 16000000
$hwstack = 100
$swstack = 100
$framesize = 100


Config Com1 = 38400 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
'*******************************************************************************
Const Sdcard = 0                                            'use SD Card = 1  no SD Card = 0
Const Lcd_mode = 2                                          'LCD Mode 1 = Porträt  Mode 2 = Landscape
'*******************************************************************************
Config Porta.0 = Output                                     'LCD CS
Config Porta.2 = Output                                     'LCD D/C
Config Porta.1 = Output                                     'LCD Reset
Lcd_cs Alias Porta.0
Lcd_dc Alias Porta.2
Lcd_reset Alias Porta.1
Porta.0 = 1
'*******************************************************************************
$include "ILI9341_declarations.inc"
'*******************************************************************************
#if Sdcard = 1
   $include "Config_MMCSD_HC.bas"
   $include "Config_AVR-DOS.bas"
   Call Init_sd_card()
#endif

'*******************************************************************************
'Config SPI   if the sd card used - SPI Config in Config_MMCSD_HC.bas
'*******************************************************************************
#if Sdcard = 0
   Config Portb.0 = Output                                  'auch wenn nicht genutzt
   Portb.0 = 1
   Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = High , Phase = 1 , Clockrate = 4 , Noss = 1
   Spsr.0 = 1
   Spiinit
#endif
'*******************************************************************************



'used for demo
Dim Zahler As Word , Dumb As Word


'*******************************************************************************

Call Lcd_init()                                             'INIT Display

'*******************************************************************************
Do
'*******************************************************************************
'*******************************************************************************
'     Portrait Mode
'*******************************************************************************
'*******************************************************************************
#if Lcd_mode = 1
   Call Lcd_clear(black)
   Call Lcd_text( "Hallo World" , 10 , 50 , 3 , Red , White , 1)
   Restore Mcse
   Call Lcd_show_bgc(54 , 100)
   Wait 1
    Call Lcd_clear(red)
 #if Sdcard = 1
   Call Lcd_pic_binsd( "101.bin" , 10 , 10 , 72 , 72)
   Wait 2
   Call Lcd_pic_binsd( "016.bin" , 0 , 0 , 240 , 320)
   Wait 2
   Call Lcd_clear(red)
 #endif
   Call Lcd_clear(black)
   Call Lcd_text( "Box" , 10 , 10 , 2 , Blue , White , 1)
   Call Lcd_box(10 , 50 , 100 , 100 , 2 , Red , Cyan0)
   Call Lcd_box(120 , 50 , 100 , 100 , 1 , Red , Cyan0)
   Call Lcd_box(10 , 160 , 100 , 100 , 3 , Red , Cyan0)

   Wait 3
   Call Lcd_clear(black)
   Call Lcd_text( "Hallo World" , 10 , 50 , 2 , Blue , White , 1)
   Call Lcd_circle(100 , 100 , 20 , Yellow)
   Call Lcd_circle(100 , 200 , 20 , Yellow)
   Wait 1
   Call Lcd_clear(black)
   Call Lcd_line(1 , 100 , 239 , 100 , 1 , Blue)
   Call Lcd_line(1 , 130 , 239 , 130 , 2 , Red)

   Call Lcd_line(120 , 1 , 120 , 319 , 2 , Red)
   Call Lcd_line(1 , 1 , 239 , 319 , 2 , Yellow)
   Call Lcd_line(239 , 1 , 1 , 319 , 2 , Green)
   Wait 1
   Call Lcd_clear(blue)
    Call Lcd_text( "BGC Files" , 10 , 10 , 2 , Blue , Red , 1)
    Restore Miky1
    Call Lcd_show_bgc(20 , 30)
    Restore Miky1
    Call Lcd_show_bgc(20 , 180)
    Wait 2                                                  '
#endif
'*******************************************************************************
'*******************************************************************************
'     Landscape Mode
'*******************************************************************************
'*******************************************************************************
#if Lcd_mode = 2
   Call Lcd_clear(black)
  Call Lcd_text( "Hello World" , 30 , 20 , 2 , Blue , Black , 2)
   Call Lcd_text( "ILI9341 Display 320x240" , 20 , 70 , 2 , Yellow , Black , 1)

   Restore Mcse
   Call Lcd_show_bgc(95 , 100)

   Call Lcd_line(0 , 0 , 319 , 0 , 2 , Red)
   Call Lcd_line(0 , 238 , 319 , 238 , 2 , Red)
   Call Lcd_line(0 , 0 , 0 , 239 , 2 , Red)
   Call Lcd_line(318 , 0 , 318 , 239 , 2 , Red)
   Wait 3

   Call Lcd_clear(black)
   Call Lcd_text( "Hello" , 130 , 10 , 2 , Red , Black , 1)
   Call Lcd_text( "Hello" , 100 , 35 , 2 , Yellow , Black , 2)
   Call Lcd_text( "Hello" , 70 , 80 , 2 , Green , Black , 3)
   Call Lcd_text( "Hello" , 40 , 140 , 2 , White , Black , 4)
   Wait 3
   Call Lcd_clear(black)
'-------------------------------------------------------------------------------
 #if Sdcard = 1
   Call Lcd_pic_binsd( "1501.bin" , 5 , 5 , 150 , 113)
   Call Lcd_pic_binsd( "1502.bin" , 160 , 5 , 150 , 113)
   Call Lcd_pic_binsd( "1503.bin" , 160 , 120 , 150 , 113)
   Call Lcd_pic_binsd( "1504.bin" , 5 , 120 , 150 , 113)
   Wait 2
   Call Lcd_pic_binsd( "007.bin" , 0 , 0 , 320 , 240)
   Wait 2
   Call Lcd_clear(red)
 #endif
'-------------------------------------------------------------------------------
   Call Lcd_clear(black)
   Call Lcd_text( "Box" , 10 , 10 , 2 , Blue , Black , 1)
   Call Lcd_box(60 , 50 , 200 , 140 , 1 , Red , Cyan0)      'box fill
   Call Lcd_box(70 , 60 , 180 , 120 , 1 , Blue , Cyan0)
   Call Lcd_box(80 , 70 , 160 , 100 , 1 , Yellow , Cyan0)
   Call Lcd_box(90 , 80 , 140 , 80 , 1 , Magenta , Cyan0)
   Call Lcd_box(100 , 90 , 120 , 60 , 1 , Light_green , Cyan0)
   Call Lcd_box(110 , 100 , 100 , 40 , 1 , Brown , Cyan0)

   Wait 2
   Call Lcd_clear(black)
   Call Lcd_text( "Box" , 10 , 10 , 2 , Blue , Black , 1)
   Call Lcd_box(60 , 50 , 200 , 140 , 2 , Red , Cyan0)      'box fill with border
   Call Lcd_box(70 , 60 , 180 , 120 , 2 , Blue , Green)
   Call Lcd_box(80 , 70 , 160 , 100 , 2 , Yellow , Red)
   Call Lcd_box(90 , 80 , 140 , 80 , 2 , Magenta , White)
   Call Lcd_box(100 , 90 , 120 , 60 , 2 , Light_green , Yellow)
   Call Lcd_box(110 , 100 , 100 , 40 , 2 , Brown , Blue)

    Wait 2
   Call Lcd_clear(black)
   Call Lcd_text( "Box" , 10 , 10 , 2 , Blue , Black , 1)
   Call Lcd_box(60 , 50 , 200 , 140 , 3 , Red , Cyan0)      'only border
   Call Lcd_box(70 , 60 , 180 , 120 , 3 , Blue , Green)
   Call Lcd_box(80 , 70 , 160 , 100 , 3 , Yellow , Red)
   Call Lcd_box(90 , 80 , 140 , 80 , 3 , Magenta , White)
   Call Lcd_box(100 , 90 , 120 , 60 , 3 , Light_green , Yellow)
   Call Lcd_box(110 , 100 , 100 , 40 , 3 , Brown , Blue)

   Wait 1
   Call Lcd_clear(black)
   Call Lcd_text( "Font" , 100 , 10 , 2 , Yellow , Black , 2)       'Font Bold x2
   Call Lcd_text( "12x16" , 88 , 85 , 2 , Yellow , Black , 2)
   Call Lcd_text( "x2" , 124 , 140 , 2 , Yellow , Black , 2)
   Wait 1
   Call Lcd_clear(black)
   Call Lcd_text( "Font" , 88 , 10 , 2 , Yellow , Black , 3)       'Font Bold x3
   Call Lcd_text( "12x16" , 64 , 85 , 2 , Yellow , Black , 3)
   Call Lcd_text( "x3" , 112 , 150 , 2 , Yellow , Black , 3)
   Wait 1
   Call Lcd_clear(black)
   Call Lcd_text( "Font" , 64 , 10 , 2 , Yellow , Black , 4)       'Font Bold x4
   Call Lcd_text( "12x16" , 40 , 85 , 2 , Yellow , Black , 4)
   Call Lcd_text( "x4" , 100 , 160 , 2 , Yellow , Black , 4)
   Wait 1
   Call Lcd_clear(black)
'-------------------------------------------------------------------------------
   Call Lcd_text( "Line" , 10 , 10 , 2 , Blue , Black , 1)
   For Dumb = 50 To 190 Step 5
      Call Lcd_line(1 , 120 , 300 , Dumb , 1 , Yellow)
   Next

   For Dumb = 50 To 190 Step 5
      Call Lcd_line(319 , 120 , 19 , Dumb , 1 , Green)
   Next

   For Dumb = 50 To 280 Step 5
      Call Lcd_line(160 , 239 , Dumb , 30 , 1 , Red)
   Next

   For Dumb = 50 To 280 Step 5
      Call Lcd_line(160 , 1 , Dumb , 200 , 1 , Blue)
   Next

   Wait 2
   Call Lcd_clear(white)
   Call Lcd_text( "Circle" , 10 , 10 , 2 , Blue , White , 1)
   Call Lcd_circle(160 , 120 , 20 , Red)
   For Zahler = 20 To 100 Step 5
    Call Lcd_circle(160 , 120 , Zahler , Red)
   Next

   Wait 1
   Call Lcd_clear(white)
    Call Lcd_text( "Circle" , 10 , 10 , 2 , Blue , White , 1)
   Call Lcd_fill_circle(60 , 60 , 30 , Green)
   Call Lcd_fill_circle(160 , 60 , 30 , Red)
   Call Lcd_fill_circle(260 , 60 , 30 , Blue)

   Call Lcd_fill_circle(60 , 140 , 20 , Red)
   Call Lcd_fill_circle(160 , 140 , 20 , Blue)
   Call Lcd_fill_circle(260 , 140 , 20 , Green)

   Call Lcd_fill_circle(60 , 190 , 10 , Blue)
   Call Lcd_fill_circle(160 , 190 , 10 , Green)
   Call Lcd_fill_circle(260 , 190 , 10 , Red)

   Wait 2
   Call Lcd_clear(black)
   Call Lcd_text( "BGC Files" , 10 , 10 , 2 , Yellow , Black , 2)

   Restore Miky1
   Call Lcd_show_bgc(200 , 100)
   Restore Miky1
   Call Lcd_show_bgc(20 , 100)

   Wait 2

#endif
'*******************************************************************************
Loop
End
'*******************************************************************************
$include "ILI9341_routines.inc"

#if Sdcard = 1
   $include "SD_card_init.inc"
#endif

$include "Font/Font12x16.font"
'$include "Font/Font8x8.font"     'weitere Fonts müssen in der Sub Lcd_Text eingebunden werden
'$include "Font/crn20x24.font"
'*******************************************************************************
Miky1:
$bgf "Sd Card\miky1.bgc"
Mcse:
$bgf "Sd Card\mcse.bgc"



 


i don't know how to fix it, please help me
Back to top
View user's profile Visit poster's website
davematt

Bascom Member



Joined: 25 May 2004
Posts: 6
Location: Gippsland, Australia

PostPosted: Sun Mar 08, 2015 1:30 am    Post subject: Asm problem Reply with quote

Hi all, I have a 2.4in version using this chip driven by a M32 and soft SPI. Hkipnik's early code works fine, but as soon as I try routines with assembly for speed, my M32 hangs. Hope I'm making a silly mistake...
This board has a touch interface using a XPT 2046. Wondering if someone could point me to some code?
Cheers, Dave.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Goto page Previous  1, 2, 3, 4, 5  Next
Page 3 of 5

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum