View previous topic :: View next topic |
Author |
Message |
Meister
Joined: 27 May 2010 Posts: 319
|
Posted: Sat Sep 10, 2016 2:42 pm Post subject: glcdEADOGMXL240-7-I2C.lib on Xmega? |
|
|
Hello,
I found the "glcdEADOGMXL240-7-I2C.lib" and a sample code in the Bascom directory.
But on an Xmega128A1 I received a bunch of errors.
On the M328 it compiles.
Is there a version for the Xmega available?
Some of the errors:
Error : 222 Line : 2 Illegal character [expected (, got '' [_SDA]] , in File : C:\PROGRAM FILES (X86)\MCS ELECTRONICS\BASCOM-AVR\LIB\I2C_TWI.LBX
Error : 1 Line : 2 Unknown statement [.EQU not found for:_SDADDR] , in File : C:\PROGRAM FILES (X86)\MCS ELECTRONICS\BASCOM-AVR\LIB\I2C_TWI.LBX
Error : 387 Line : 5 IO address must be in range [0-31] [_SCLPORT] , in File : C:\PROGRAM FILES (X86)\MCS ELECTRONICS\BASCOM-AVR\LIB\I2C_TWI.LBX
Regards, Meister
(BASCOM-AVR version : 2.0.8.0 , Latest : 2.0.7.8 ) |
|
Back to top |
|
|
Meister
Joined: 27 May 2010 Posts: 319
|
Posted: Sun Sep 11, 2016 9:20 pm Post subject: |
|
|
Hello,
I realized that using the I2C Bus is slightly different between Megas and Xmegas, so please forget the error codes posted above ...
Having learned that lesson I combined a working Xmega I2C scanning code
with the working M328 display code for the EADOGMXL240-7 (both from the samples directory).
The combined code compiles and does the I2C scan correctly but the display does not respond.
On the I2C bus the scan data are seen by a logic analyzer,
but no further data for the display are appearing.
Also without the I2C sanning code nothing is sent to GLCD.
So it look like the glcdEADOGMXL240-7-I2C.lib is not compatible wit the Xmega.
Is there any suggestion how get the display running?
Best regards, Meister
Code: | $regfile = "xm128a1def.dat"
$crystal = 32000000
$hwstack = 64
$swstack = 40
$framesize = 40
Dim S As String * 20
Config Osc = Enabled , 32mhzosc = Enabled
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1
Config Twic = 400000
Config Com1 = 19200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
Open "COM1:" For Binary As #1
Dim Twi_start As Byte , J As Byte , B As Byte
Print "Scan start"
I2cinit
For B = 0 To 254 Step 2 'for all odd addresses
I2cstart 'send start
I2cwbyte B 'send address
If Err = 0 Then 'we got an ack
Print "........Slave at : " ; B ; " hex : " ; Hex(b) ; " bin : " ; Bin(b)
End If
I2cstop 'free bus
Next
Print "End Scan"
'I2cstop
'I2cinit
'---------------------------------------------------------------------------------------------------------------
$lib "glcdEADOGMXL240-7-I2C.lib" 'override the default lib with this special one
#if _build < 2078
Dim ___lcdrow As Byte , ___lcdcol As Byte
#endif
Config Graphlcd = Custom , Cols = 240 , Rows = 128 , Lcdname = "EADOGXL240-7"
Cls
Waitms 20
Setfont Font8x8
Lcdat 1 , 1 , "11111111"
Lcdat 2 , 1 , "88888888"
Lcdat 12 , 64 , "MCS Electronics" , 1
Circle(30 , 30) , 20 , 255
Line(0 , 0) -(239 , 127) , 255 ' diagonal line
Line(0 , 127) -(239 , 0) , 255 ' diagonal line
End
$include "font8x8.font" |
|
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Mon Sep 12, 2016 9:01 am Post subject: |
|
|
If the I2C scan doesn't see anything then there's a problem with hardware or settings.
An I2C device should always response with an ACK even if the lcd isn't supported.
Edit: Missing the Open "twic" For Binary As #4 and some other I2C stuff in your code, have a look at the sample in the helpfile. _________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
Meister
Joined: 27 May 2010 Posts: 319
|
Posted: Mon Sep 12, 2016 9:59 am Post subject: |
|
|
Quote: | Missing the Open "twic" For Binary As #4 and some other I2C stuff in your code, have a look at the sample in the helpfile.
|
That does not seem to be required.
Without that this sample code works :
Code: | '------------------------------------------------------------------
' (c) 1995-2014 MCS
' xmega-scanner.bas
'purpose : scan all i2c addresses to find slave chips
'Micro: Xmega128A1
'------------------------------------------------------------------
$regfile = "xM128a1def.dat" ' the used chip
$crystal = 32000000 ' frequency used
$hwstack = 40
$swstack = 40
$framesize = 40
'first enable the osc of your choice
Config Osc = Enabled , 32mhzosc = Enabled
'configure the systemclock
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1
Config Com1 = 19200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
'Config Serialin = Buffered , Size = 50
Config Twic = 100000 'CONFIG TWI will ENABLE the TWI master interface
'Enable Interrupts
Open "COM1:" For Binary As #1
I2cinit
Dim Twi_start As Byte , J As Byte , B As Byte
Print "Scan start"
For B = 0 To 254 Step 2 'for all odd addresses
I2cstart 'send start
I2cwbyte B 'send address
If Err = 0 Then 'we got an ack
Print "Slave at : " ; B ; " hex : " ; Hex(b) ; " bin : " ; Bin(b)
End If
I2cstop 'free bus
Next
Print "End Scan"
End |
So I assume the I2C calls in the glcdEADOGMXL240-7-I2C.lib
end up in the sky for the Xmega...
Those I2C calls are in that Lib:
_call _i2c_stop
_call _i2c_start
_call _i2c_write
_call _i2c_read_more
_call _i2c_read_last
Could those be replaced in the glcdEADOGMXL240-7-I2C.lib
by the built-in routines which are working for the Xmega:
I2CStop
I2CStart
I2cwbyte
I2crbyte
Thanks for any help.
Best Regards, Meister |
|
Back to top |
|
|
|
|
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
|
|