View previous topic :: View next topic |
Author |
Message |
balou
Joined: 14 Apr 2007 Posts: 36
|
Posted: Wed Dec 22, 2021 10:32 am Post subject: Problem Attiny85 and I2C Oled. |
|
|
Problem Attiny85 and I2C Oled.
Config Scl = Portb.3
Config Sda = Portb.4
The program works perfectly.
But if I change this
Config Scl = Portb.1
Config Sda = Portb.2
It doesn't work.
Measured with scope on B.1 and B.2 I see no signal.
What am I doing wrong ?
balou.
************ program ************
$regfile = "ATtiny85.DAT"
$crystal = 8000000
$hwstack = 40
$swstack = 16
$framesize = 32
Config Scl = Portb.3
Config Sda = Portb.4
I2cinit
$lib "glcdSSD1306-I2C.lib"
Waitms 5
Config Graphlcd = Custom , Cols = 128 , Rows = 64 , Lcdname = "SSD1306"
'-------------------------------- Program --------------------------------------
Setfont Font6x8
Do
Cls
Lcdat 1 , 30 , "SSD1306"
Wait 1
Loop
End
'************** Include ******************
$include "fonts/font6x8.font"
(BASCOM-AVR version : 2.0.8.4 ) _________________ Bascom-AVR 2.0.8.5 |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Wed Dec 22, 2021 1:36 pm Post subject: Re: Problem Attiny85 and I2C Oled. |
|
|
balou wrote: | What am I doing wrong ? |
Leaving the programmer connected while testing or leaving out pullups. |
|
Back to top |
|
|
balou
Joined: 14 Apr 2007 Posts: 36
|
Posted: Wed Dec 22, 2021 1:47 pm Post subject: |
|
|
Program connector in / out.
Pullups connected
No difference. _________________ Bascom-AVR 2.0.8.5 |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Wed Dec 22, 2021 3:49 pm Post subject: |
|
|
I give you like this : it is a counter for votation its works with 2 AA battery
working with t85 and SSD1306
Code: |
'programme boite à vote 22-10-2019
'Attinny 85 JP Duval pour Longpont 02600 France-------------------------------------------------------------
'5 broches utilisables
'B.0 SDA
'B.1 contact vote 1
'B.2 SCL
'B.3 contact zero 2
'B.4 non utilisé
'B.5 réservé au reset
'-----------Microcontroleur------------------------------------------------------------------------------------------------
$regfile = "attiny85.dat"
$crystal = 1000000
$hwstack = 40
$swstack = 40
$framesize = 40
'---- config------------------------------------------------------------------------------------------------------------------
Config Clockdiv = 8
Config Submode = New
'-------------------------------- I2C bus Tiny85--------------------------------------------------------------------------
Config Sda = Portb.0
Config Scl = Portb.2
I2cinit
Waitms 5
' -------les ports------------------------------------------------------------------------------------------------------------
Vote Alias Portb.1
Raz Alias Portb.3
Config Vote = Input
Config Raz = Input
Set Vote 'activation des pull up
Set Raz
'display---------------------------------------------------------------------------------------------------------------------
$lib "glcdSSD1306-I2C.lib"
Config Graphlcd = Custom , Cols = 128 , Rows = 64 , Lcdname = "SSD1306"
Dim Lcd_auto As Byte
Lcd_auto = 1
Enable Interrupts
'----var-----------------------------------------------------------------------------------------------------------------------
Dim Compteur As Integer
Dim Regb As Byte
Dim Memoire As Eram Integer
Dim Fxmem As Integer
Dim Stcomp As String * 3
Dim Flagzero As Byte
'---prog----------------------------------------------------------------------------------------------------------------------
Compteur = 0
Fxmem = Memoire 'lecture mémoire
If Fxmem => 0 Then Compteur = Memoire
Setfont Font12x16
Cls
Lcdat 4 , 1 , " LONGPONT"
Setfont Font20x24jp ' font modifiée Lettre MAJ et chiffre uniquement
Stcomp = Str(compteur) : Stcomp = Format(stcomp , "000")
If Compteur = 0 Then
Lcdat 1 , 40 , "ZERO"
Flagzero = 1
End If
'lecture switch-------------------------------------------------------------------------------------------------------------
Function Liresw() As Byte
Local Sw As Byte
If Pinb.1 = 0 Then 'vote
Waitms 50 'anti-rebond
If Pinb.1 = 0 Then
While Pinb.1 = 0
Waitms 10
Wend
Sw = 1
End If
Elseif Pinb.3 = 0 Then 'RAZ
Sw = 2
Else
Sw = 0
End If
Liresw = Sw
End Function
'-------main------------------------------------------------------------------------------------------------------------------
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
End 'end program
$include "font12x16.font"
$include "Font20x24jp.font"
'
'$prog &HFC , &HE2 , &HDF , &HFF ' generated. fuse bitTake care that the chip supports all fuse bytes. |
jp _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Wed Dec 22, 2021 7:23 pm Post subject: |
|
|
balou wrote: | Program connector in / out.
Pullups connected
No difference. |
Write some small code to toggle the pins in question. |
|
Back to top |
|
|
balou
Joined: 14 Apr 2007 Posts: 36
|
Posted: Wed Dec 22, 2021 7:40 pm Post subject: |
|
|
I have write a code to togle the pins.
All pins are oke.
I also treid this, also does not work.
Config Sda = Portb.0
Config Scl = Portb.2
Other Attiny85 doesn't work. _________________ Bascom-AVR 2.0.8.5 |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Wed Dec 22, 2021 9:16 pm Post subject: |
|
|
It's no SW issue.
Compiled each version, 1_2 & 3_4, disassembled the hex and compared.
Only the port-related opcodes differ, everything else is exact the same.
For example the one reads
Code: | sbi p17,b1
cbi p17,b2
cbi p17,b1 | and the other
Code: | sbi p17,b3
cbi p17,b4
cbi p17,b3 |
I've added a config to slow down the bus, just in case.
Code: | $regfile = "ATtiny85.DAT"
$crystal = 8000000
$hwstack = 40
$swstack = 16
$framesize = 32
Config Scl = Portb.3
Config Sda = Portb.4
Config I2CDelay = 10
I2cinit
$lib "glcdSSD1306-I2C.lib"
Waitms 5
Config Graphlcd = Custom , Cols = 128 , Rows = 64 , Lcdname = "SSD1306"
'-------------------------------- Program --------------------------------------
Setfont Font6x8
Do
Cls
Lcdat 1 , 30 , "SSD1306"
Wait 1
Loop
End
'************** Include ******************
$include "my6_8.font" |
Not sure if I use the correct font, but you can try the attached hex-files, at least there should be activity on the pins.
You need to rename the attached file's bas-extension to hex, the forum software showed to fuss about hex. |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Thu Dec 23, 2021 3:43 pm Post subject: |
|
|
As the ATiny85 supports the SPM command, it is possible that a boot loader is installed.
Would you tell how you program the Tiny, ISP or serial via USB/RS232?
Also I'd like to see the fuse settings. |
|
Back to top |
|
|
balou
Joined: 14 Apr 2007 Posts: 36
|
Posted: Thu Dec 23, 2021 4:24 pm Post subject: |
|
|
Good afternoon,
I found the problem.
It's a breadboard from china, bad connections.
Now it works with a "real breadboard ".
I program the Tiny with ISP. Fuses setting "Spien, Int. osc 8 Mhz."
Thanks everyone for all the response.
Balou _________________ Bascom-AVR 2.0.8.5 |
|
Back to top |
|
|
|