View previous topic :: View next topic |
Author |
Message |
krolikbest
Joined: 02 Jan 2017 Posts: 112
![poland.gif](https://www.mcselec.com/components/com_forum/images/flags/poland.gif)
|
Posted: Wed Jan 01, 2020 7:03 pm Post subject: sh1106-i2c |
|
|
Hi
first of all- Happy New 2020 and perhaps first question in 2020
have graphic lcd 1.3 inch with driver sh1106 i2c.It has 4 pins:
-vcc (3.3v to 5v) ->connected to 5v of arduino
-grnd ->connected to grnd of arduino
-sda -> connected to sda of arduino
-scl -> connected to scl of arduino
I got it run with arduino uno but noticed that when I use routine wait/waitms in loop lcd get blank screen and reset of arduino doesn't help.
Below my simply code i tested lcd with
Code: |
$regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack = 40
$swstack = 40
$framesize = 40
$lib "i2c_twi.lbx"
$lib "glcdSH1106-I2C.lib"
Config Twi = 400000
Config Scl = Portc.5
Config Sda = Portc.4
Config Portc.3 = Output
I2cinit
Lcd_reset Alias Portc.3
Lcd_reset = 0
Waitms 100
Lcd_reset = 1
Waitms 100
Config Graphlcd = Custom , Cols = 128 , Rows = 64 , Lcdname = "SSD1306"
cls
Do
Setfont Font8x8tt
Lcdat 1 , 1 , "103"
Lcdat 2 , 2 , "222"
'wait 1 [b]<-that simply hang up...[/b]
Lcdat 3 , 2 , "whatever" ; i
Loop
End
$include "Font8x8TT.font"
|
It looks like "wait" cannot cooperate with some routines from glcdSH1106-I2C library... maybe..
Regards,
Martin
(BASCOM-AVR version : 2.0.8.0 , Latest : 2.0.8.2 ) |
|
Back to top |
|
![](https://www.mcselec.com/components/com_forum/templates/subSilver/images/spacer.gif) |
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
![france.gif](https://www.mcselec.com/components/com_forum/images/flags/france.gif)
|
Posted: Thu Jan 02, 2020 10:15 am Post subject: |
|
|
did you see the help about GLCDdSSD1306-I2C ?
is it working for you ?
do you have pull up R 4.7k on line SDA SCL ?
Happy new year
jp _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
![](https://www.mcselec.com/components/com_forum/templates/subSilver/images/spacer.gif) |
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
![france.gif](https://www.mcselec.com/components/com_forum/images/flags/france.gif)
|
|
Back to top |
|
![](https://www.mcselec.com/components/com_forum/templates/subSilver/images/spacer.gif) |
krolikbest
Joined: 02 Jan 2017 Posts: 112
![poland.gif](https://www.mcselec.com/components/com_forum/images/flags/poland.gif)
|
Posted: Thu Jan 02, 2020 2:38 pm Post subject: |
|
|
Thank for your reply. Yes I've read about ssd1306-i2c but I use library for sh1106-i2c. basically it works but when it comes to execute "wait" statement then oled screen is blank and rest of the program seems to stop. Without "wait" i can even make animation and it looks very good.
There is no difference if I use or not 4.7K resisors. Actually i don't use, but using them the effect is the same- on "wait" statement program stops.
Regards,
Martin |
|
Back to top |
|
![](https://www.mcselec.com/components/com_forum/templates/subSilver/images/spacer.gif) |
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
![blank.gif](https://www.mcselec.com/components/com_forum/images/flags/blank.gif)
|
Posted: Thu Jan 02, 2020 2:53 pm Post subject: |
|
|
you should check this : $crystal = 16000000
Is the clock actual 16 Mhz ?
Instead of wait, use waitms and see how long it actually takes.
first try waitms 1
then 10, 100 and finally 1000 _________________ Mark |
|
Back to top |
|
![](https://www.mcselec.com/components/com_forum/templates/subSilver/images/spacer.gif) |
krolikbest
Joined: 02 Jan 2017 Posts: 112
![poland.gif](https://www.mcselec.com/components/com_forum/images/flags/poland.gif)
|
Posted: Thu Jan 02, 2020 5:36 pm Post subject: |
|
|
Hi Mark,
tested this code:
Code: |
$regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack = 40
$swstack = 40
$framesize = 40
$lib "i2c_twi.lbx"
$lib "glcdSH1106-I2C.lib"
Config Twi = 400000
Config Scl = Portc.5
Config Sda = Portc.4
Config Portc.3 = Output
I2cinit
Lcd_reset Alias Portc.3
Lcd_reset = 0
Waitms 100
Lcd_reset = 1
Waitms 100
Config Graphlcd = Custom , Cols = 128 , Rows = 64 , Lcdname = "SSD1306"
cls
Do
waitms 1
cls
Setfont Font8x8tt
Lcdat 8 , 5 , "test test"
Loop
End
$include "Font8x8TT.font"
|
it seems that there is no difference between 10 or 1000 ms. For waitms=1 ms or waitms=2 ms it seems to work, but higher values make screen blank. if "waitms" i commented it works.
Regards,
Martin |
|
Back to top |
|
![](https://www.mcselec.com/components/com_forum/templates/subSilver/images/spacer.gif) |
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
![blank.gif](https://www.mcselec.com/components/com_forum/images/flags/blank.gif)
|
Posted: Fri Jan 03, 2020 11:27 am Post subject: |
|
|
you best display a counter which you increase inside the loop.
this way you can detect a reset.
it really does not make any sense that waitms does not work so it is most likely some hardware problem. a reset for example. _________________ Mark |
|
Back to top |
|
![](https://www.mcselec.com/components/com_forum/templates/subSilver/images/spacer.gif) |
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
![france.gif](https://www.mcselec.com/components/com_forum/images/flags/france.gif)
|
Posted: Fri Jan 03, 2020 4:54 pm Post subject: |
|
|
in my little program I use wait
Code: |
Do
Regb = Liresw()
If Regb = 1 And Compteur = 0 Then Cls
Select Case Regb
Case 1
Compteur = Compteur + 1
Stcomp = Str(compteur) : Stcomp = Format(stcomp , "000")
Lcdat 1 , 50 , Stcomp
Memoire = Compteur 'mise en EEprom
Case 2 'raz
Compteur = 0
Cls
Lcdat 1 , 1 , "RAZ:" ; Compteur
Wait 1
Cls
Memoire = Compteur 'mise en EEprom
Goto 0 'reinitialise le µp
End Select
Loop |
So as Mark I think is is not a Bascom problem _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
![](https://www.mcselec.com/components/com_forum/templates/subSilver/images/spacer.gif) |
krolikbest
Joined: 02 Jan 2017 Posts: 112
![poland.gif](https://www.mcselec.com/components/com_forum/images/flags/poland.gif)
|
Posted: Fri Jan 03, 2020 9:03 pm Post subject: |
|
|
Hello,
actually i'm a bit confused. I lowered crystal to 8MHz (normally 16MHz) and then I could use waitms till 300 ms. if crystal is 16MHz i couldn't use waitms higher than 2ms.
I noticed that if in program now I use waitms > 300, e.g.
Code: |
cls
Setfont Font8x8
Lcdat 7 , 6 , "test test" , 0
waitms 400
|
it can work normally but after some time the text is displayed in random positions instead x,y, sometimes presumably above an acceptable range (128x64), that is why screen is blank then. The higher waitms value the more often screen is blank. So it is not a "wait" problem, now it looks like the problem is really on the display side strictly speaking with data transfer through i2c service. Anyway I'll work around it. Thank you for helping me.
Regards,
Martin |
|
Back to top |
|
![](https://www.mcselec.com/components/com_forum/templates/subSilver/images/spacer.gif) |
|