Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Update 2079 -> 2081, XMEGA, I2C on twie problem
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Unsupported versions
View previous topic :: View next topic  
Author Message
MDuprau

Bascom Member



Joined: 13 Oct 2012
Posts: 30

PostPosted: Mon Jan 07, 2019 10:42 am    Post subject: Update 2079 -> 2081, XMEGA, I2C on twie problem Reply with quote

Hello,

i update from 2079 to 2081, compile the project, start the firmware and get a problem on the second I2C bus.
One of the chip's from second I2C bus will not found anymore.

[first I2C]
open "twic" for binary as #5
config twic = 100000
i2cinit #5

[second I2C]
open "twie" for binary as #6
config twie = 100000
i2cinit #6

[2079]
<.1 i2c.1.scan=[&H68,&H98,&HA0,&HA8,&HE0]
<.1 i2c.2.scan=[&H20,&H30,&H68,&HA0]

[2081]
<.1 i2c.1.scan=[&H68,&H98,&HA0,&HA8,&HE0]
<.1 i2c.2.scan=[&H20,&H30,&HA0]

The "&H68" on the secod bus will not found

crosscheck with the firmware compiled with 2079 after the update, works, so the hardware is fine.

p.s. is this necessary on >= 2.0.7.9
$lib "xmega.lib"
$external _xmegafix_clear
$external _xmegafix_rol_r1014

BASCOM AVR 2.0.8.1 -> back to 2.0.7.9

Best Regards Mark

(BASCOM-AVR version : 2.0.8.1 )
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5071
Location: Holland

blank.gif
PostPosted: Mon Jan 07, 2019 11:15 am    Post subject: Reply with quote

I really hate these kind of postings.
Some problem is reported and then there is some sort of proof, but the code is just a fragment. it can not be checked since it can not be compiled as is. There is no info about the processor.
There is also a question missing about the problem. So what is this kind of post?

When you have a problem and want help you need to post an example that will demo the problem. And we need to be able to compiler without assumptions.

Then, you should not put other unrelated questions inside the post.
Just take some time for your posting.

And the BASCOM AVR 2.0.8.1 > back to 2.0.7.9 : What good is that information? does this mean you dont not care about the problem? So you post a problem but do not care since you installed an old version?
If you dont care we dont either.

_________________
Mark
Back to top
View user's profile Visit poster's website
MDuprau

Bascom Member



Joined: 13 Oct 2012
Posts: 30

PostPosted: Mon Jan 07, 2019 3:34 pm    Post subject: Reply with quote

Hello,

sorry, but i cant post here a project that goes over more then 35.000 codelines.

The MCU is a XMEGA defined in "xm256a3udef.dat".

[code to open the I2C on "twic"]
Code:
open "twic" for binary as #5
config twic = 100000
i2cinit #5


[codepart to scan the I2C on "twic"]
Code:
   local i as byte
               for i = 2 to 254 step 2
                  i2cstart #5
                  i2cwbyte i , #5
                  if err = 0 then
                     print #buart_channel , "&H" ; hex(i)
                  end if
                  i2cstop #5
                  err = 0
               next


[code to open the I2C on "twie"]
Code:
open "twie" for binary as #6
config twie = 100000
i2cinit #6


[codepart to scan the I2C on "twie"]
Code:
   local i as byte
               for i = 2 to 254 step 2
                  i2cstart #6
                  i2cwbyte i , #6
                  if err = 0 then
                     print #buart_channel , "&H" ; hex(i)
                  end if
                  i2cstop #6
                  err = 0
               next


[codepart from device check on "twie"]
Code:
   i2cstart #6
   i2cwbyte &H68 , #6
   if err = 0 then
      ....
   end if
   i2cstop #6


You see the "base" is 100% the same, and on each bus lines is one of the missing chip, on one bus its presend on one not.

I cant use the 2.0.8.1 atm. with an error like this, that is the reason why i must go back to the 2.0.7.9.

p.s. and i think the transfer it do a "old" BASCOM forum is wrong, but its on you.

Best Regards Mark


Last edited by MDuprau on Mon Jan 07, 2019 4:34 pm; edited 1 time in total
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5071
Location: Holland

blank.gif
PostPosted: Mon Jan 07, 2019 3:55 pm    Post subject: Reply with quote

- when posting code, please use code tags.
- I do not ask for complete code : i ask for the smallest possible code that will demo the problem. I do not ask for fragments which do not mean a thing without context.
- this forum is for older compilers which we do not support and for cases like this where i do not want to spend my time on because the lack of info. it is a good idea to rename this forum.

_________________
Mark
Back to top
View user's profile Visit poster's website
MDuprau

Bascom Member



Joined: 13 Oct 2012
Posts: 30

PostPosted: Mon Jan 07, 2019 5:14 pm    Post subject: Reply with quote

Hello,

i make an update to highlight the code, but in this case it makes no different, without the hardware you cant check anything with my code.

All i can do is, to check this here and give you all information i have.

Firmware and Hardware runs without any problems on 2.0.7.9.
After the update to 2.0.8.1 a device on TWIE will not found, his "brother" on TWIC will be found.
A release compiled with 2.0.7.9, after the update with 2.0.8.1 and back to 2.0.7.9, same codebase, runs without problems.

Results from scan:
[2079]
<.1 i2c.1.scan=[&H68,&H98,&HA0,&HA8,&HE0]
<.1 i2c.2.scan=[&H20,&H30,&H68,&HA0]

[2081]
<.1 i2c.1.scan=[&H68,&H98,&HA0,&HA8,&HE0]
<.1 i2c.2.scan=[&H20,&H30,&HA0] ???

The Hexfile from 2.0.7.9 is 566181 bytes, from 2.0.8.1 is 566434 bytes

I doublecheck this now with both version on the same codebase, the 2.0.8.1 dint found the device.

Compare over the [_I2C] code segment in inside "xmega.lib" show your document changes for the "i2cstop" versions, but also changes on "_i2c_bus_state".
Next i will try it with the code segments from 2.0.7.9 inside the 2.0.8.1 "xmega.lib", "_i2c_bus_state" and/or "_i2c_stop".

Best Regards Mark
Back to top
View user's profile
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 695

poland.gif
PostPosted: Mon Jan 07, 2019 5:58 pm    Post subject: Reply with quote

Please do some tests Wink Attach &H20 and &H30 device on the first line too.
Are &H68 visible on the first line then?
NO-> Try to configure I2cStop like Help provide. Maybe it will help.
Quote:
Const _TWI_STOP_1 = 1
or
Const _TWI_STOP_2 = 1

Without those constants it should behave like 2079 but test new feature should take less than new post.
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5071
Location: Holland

blank.gif
PostPosted: Mon Jan 07, 2019 8:39 pm    Post subject: Reply with quote

the i2cstop command in 2079 is the same as in 2081 when none of the constants are defined.
The problem is that the internal xmega twi logic does not respond properly to a stop command in some cases. so in 2079 the stop command is done in a loop.
But this gave problems with some new xmega chips. So in 2080 a constant was added to control the behavior. The problem was that it broke compatibility with the previous version so in 2081 the behavior was like in 2079 and the 2 modes were made optional. if you check the 2079 and the 2081 you will see that.

while you can make all kind of experiments, it is best if you create a short sample program that will have the problem. there can be multitude of reasons why it will work different.

_________________
Mark
Back to top
View user's profile Visit poster's website
MDuprau

Bascom Member



Joined: 13 Oct 2012
Posts: 30

PostPosted: Mon Jan 07, 2019 11:48 pm    Post subject: Reply with quote

first checks done
background information : the device scan on "twic" and "twie" is part of the initialisation, so for me each test takes some minutes.

BASCOM 2.0.8.1 GUI (restart and compile after each change, before change all files are origin) :
- with "xmega.lib" from 2.0.7.9 stuck on "twie" device scan, non of the devices will shown here, "twic" work fine
- with "xmega.lib" and "xm256A3Udef.dat" from 2.0.7.9 stuck on "twie" device scan, non of the devices will shown here, "twic" work fine
- with "xm256A3Udef.dat" from 2.0.7.9 "twie" device scan show all devices, except &H68, "twic" work fine
- with the complete [_I2C] section from 2.0.7.9 "xmega.lib" stuck on "twie" device scan, non of the devices will shown here, "twic" work fine
- with the [_I2C]_i2c_bus_state: section from 2.0.7.9 "xmega.lib" stuck on "twie" device scan, non of the devices will shown here, "twic" work fine
- with the [_I2C]_i2c_stop: section from 2.0.7.9 "xmega.lib" "twie" device scan show all devices, except &H68, "twic" work fine
- with "Const _TWI_STOP_1 = 1" "twie" device scan show all devices, except &H68, "twic" work fine
- with "Const _TWI_STOP_2 = 1" "twie" device scan show all devices, except &H68, "twic" work fine, stuck on the first access on the EEPROM on "twic"
- with non "Const _TWI_STOP_X = 1" "twie" device scan show all devices, except &H68, "twic" work fine

if i remove the incompatibilities from "_TWI_STOP_2", all the test cases points to a handling problem on "twie", non of the errors will shown on "twic".
Stuck on "twie" device scan or device not found on "twie" points to "twie" and its not inside the "xmega.lib" or "xm256A3Udef.dat".

Is there any other "code" that can "change" the handling from "twie" ?

@EDC its not possible to change the I2C devices from one I2C bus to an other, thats a finsh PCB layout, sorry

Best Regards Mark
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5071
Location: Holland

blank.gif
PostPosted: Tue Jan 08, 2019 10:35 am    Post subject: Reply with quote

these are nice tests but not needed. i still see no short sample we can test. so here is another question : the xmega i2c scanner from the help, will that show the problem for TWIE ?

Code:

'------------------------------------------------------------------
'                    (c) 1995-2015 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 Twie = 100000                                        'CONFIG TWI will ENABLE the TWI master interface
'Enable Interrupts
Open "COM1:" For Binary As #1
Open "twie" For Binary As #4                                'let use the TWIE interface

I2cinit #4

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 #4                                              'send start
   I2cwbyte B , #4                                          'send address
   If Err = 0 Then                                          'we got an ack
      Print "Slave at : " ; B ; " hex : " ; Hex(b) ; " bin : " ; Bin(b)
   End If
   I2cstop #4                                               'free bus
Next
Print "End Scan"
End
 

_________________
Mark
Back to top
View user's profile Visit poster's website
MDuprau

Bascom Member



Joined: 13 Oct 2012
Posts: 30

PostPosted: Tue Jan 08, 2019 11:58 am    Post subject: Reply with quote

Hello,

the code is near the same, but split over some files :
Code:

$regfile = "xm256a3udef.dat"
'$crystal = 16000000
$crystal = 32000000
$hwstack = 256
$swstack = 512 '1024
$framesize = 512 '1024

'include the following lib and code, the routines will be replaced since they are a workaround
$lib "xmega.lib"
$external _xmegafix_clear
$external _xmegafix_rol_r1014

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
config osc = disabled , 32khzosc = enabled, 32mhzosc = enabled                 'We use internal 32kHz & 32MHz
config sysclock = 32mhz , prescalea = 1 , prescalebc = 1_1                     'Internal 32MHz
bitwait OSC_STATUS.1 , set                                                     'Check if 32MHz Oscillator is ready
bitwait OSC_STATUS.2 , set                                                     'Check if internal 32.768 KHz Oscillator is ready
OSC_DFLLCTRL.0 = 1                                                             'enable
DFLLRC32M_CTRL.0 = 1                                                           'enable
waitms 2

config power_reduction = dummy, hiresc=off, hiresd=off, hirese=off, hiresf=off
config eeprom = mapped
config priority = roundrobin , vector = application , lo = enabled , med = enabled , hi = enabled
 


Code:

dim TWI_START as byte
 


for "twic" :
Code:

open "twic" for binary as #5
config twic = 100000
i2cinit #5
 


Code:

         debugtext = " - i2c.1 scan: "
         for i = 2 to 254 step 2
            i2cstart #5
            i2cwbyte i , #5
            if err = 0 then debugtext = debugtext + hex(i) + " "
            i2cstop #5
            err = 0
         next
 


for "twie" :
Code:

open "twie" for binary as #6
config twie = 100000
i2cinit #6
 


Code:

         debugtext = " - i2c.2 scan: "
         for i = 2 to 254 step 2
            i2cstart #6
            i2cwbyte i , #6
            if err = 0 then debugtext = debugtext + hex(i) + " "
            i2cstop #6
            err = 0
         next
 


On 2.0.7.9 everything works fine, Update to 2.0.8.1 every problem points to "twie".
Whether directly or indirectly, I can not find out here anymore.

Best Regards Mark
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5071
Location: Holland

blank.gif
PostPosted: Tue Jan 08, 2019 12:29 pm    Post subject: Reply with quote

do not bother with twic since that is working. can you confirm that this code has a problem ?
Code:

$regfile = "xm256a3udef.dat"
$crystal = 32000000
$hwstack = 256
$swstack = 512 '1024
$framesize = 512 '1024

'*******************************************************************************
config osc = disabled , 32khzosc = enabled, 32mhzosc = enabled                 'We use internal 32kHz & 32MHz
config sysclock = 32mhz , prescalea = 1 , prescalebc = 1_1                     'Internal 32MHz
bitwait OSC_STATUS.1 , set                                                     'Check if 32MHz Oscillator is ready
bitwait OSC_STATUS.2 , set                                                     'Check if internal 32.768 KHz Oscillator is ready
OSC_DFLLCTRL.0 = 1                                                             'enable
DFLLRC32M_CTRL.0 = 1                                                           'enable
waitms 2

config power_reduction = dummy, hiresc=off, hiresd=off, hirese=off, hiresf=off
config eeprom = mapped
config priority = roundrobin , vector = application , lo = enabled , med = enabled , hi = enabled
 
dim TWI_START as byte
 
open "twie" for binary as #6
config twie = 100000
i2cinit #6
 
'         debugtext = " - i2c.2 scan: "
         for i = 2 to 254 step 2
            i2cstart #6
            i2cwbyte i , #6
            if err = 0 then print hex(i)
            i2cstop #6
            err = 0
         next
 end

 

since there is no dim for debugtext i wonder if you actual tried it?
i remarked it now. please try and also try to remove the power reduction and other possible unrelated statements. only bring them in when the error was gone.

_________________
Mark
Back to top
View user's profile Visit poster's website
MDuprau

Bascom Member



Joined: 13 Oct 2012
Posts: 30

PostPosted: Tue Jan 08, 2019 3:28 pm    Post subject: Reply with quote

Hello,

sorry, "debugtext" is in one of the other 700 files of this project.

Code:

dim debugtext as string * 192
 


i must update your code to bring the hadware online :
Code:

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
$regfile = "xm256a3udef.dat"
$crystal = 32000000
$hwstack = 256
$swstack = 512 '1024
$framesize = 512 '1024

'include the following lib and code, the routines will be replaced since they are a workaround
$lib "xmega.lib"
$external _xmegafix_clear
$external _xmegafix_rol_r1014

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
config osc = disabled , 32khzosc = enabled, 32mhzosc = enabled                 'We use internal 32kHz & 32MHz
config sysclock = 32mhz , prescalea = 1 , prescalebc = 1_1                     'Internal 32MHz
bitwait OSC_STATUS.1 , set                                                     'Check if 32MHz Oscillator is ready
bitwait OSC_STATUS.2 , set                                                     'Check if internal 32.768 KHz Oscillator is ready
OSC_DFLLCTRL.0 = 1                                                             'enable
DFLLRC32M_CTRL.0 = 1                                                           'enable
waitms 2

config power_reduction = dummy, hiresc=off, hiresd=off, hirese=off, hiresf=off
config eeprom = mapped
config priority = roundrobin , vector = application , lo = enabled , med = enabled , hi = enabled

dim TWI_START as byte
dim i as byte

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
'0 = Input, 1 = Output
DDRA = &B00000111
DDRB = &B10000001
DDRC = &B10101010
DDRD = &B10001010
DDRE = &B10110010
DDRF = &B01110001

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
led_green alias PORTA.0
led_yellow alias PORTA.1
led_red alias PORTA.2

cpu_power_ctrl_out alias PORTB.7

peripheral_devices_reset2 alias PORTF.4
peripheral_devices_reset1 alias PORTF.5
cpu_power_ctrl_off alias PORTF.6

i2c1_sda alias PinC.0
i2c1_scl alias PORTC.1

i2c2_sda alias PinE.0
i2c2_scl alias PORTE.1

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
set led_red
reset cpu_power_ctrl_off
reset cpu_power_ctrl_out
reset peripheral_devices_reset1
reset peripheral_devices_reset2

waitms 1000

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
config Com3 = 115200 , mode = asynchroneous , parity = none , stopbits = 1 , databits = 8       ' use USART D0
enable Usartd0_rxc , med
'enable Usartd0_txc , med
open "COM3:" for binary as #2

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
print #2, " * start"

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
print #2, " - peripheral_devices_reset.1: " ; peripheral_devices_reset1
print #2, " - peripheral_devices_reset.2: " ; peripheral_devices_reset2

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
portc.0=1                                                                      'set both sda & scl to high to reset the I2C interface on connected devices after boot
portc.1=1
open "twic" for binary as #5
config twic = 100000
i2cinit #5

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
porte.0=1                                                                      'set both sda & scl to high to reset the I2C interface on connected devices after boot
porte.1=1
open "twie" for binary as #6
config twie = 100000
i2cinit #6

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
set led_yellow
set cpu_power_ctrl_off

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
enable interrupts
waitms 100

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
print #2, " > set peripheral_devices_reset.1"

set peripheral_devices_reset1

waitms 1000

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
print #2, " > set peripheral_devices_reset.2"

set peripheral_devices_reset2

waitms 1000

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
print #2, " - i2c.1 scan: " ;
for i = 2 to 254 step 2
   i2cstart #5
   i2cwbyte i , #5
   if err = 0 then print #2, hex(i) ; " " ;
   i2cstop #5
   err = 0
next
print #2, ""

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
print #2, " - i2c.2 scan: " ;
for i = 2 to 254 step 2
   i2cstart #6
   i2cwbyte i , #6
   if err = 0 then print #2, hex(i) ; " " ;
   i2cstop #6
   err = 0
next
print #2, ""

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
print #2, " - i2c.1 state" ; i2c1_scl ; ", " ; i2c1_sda ; ", &H" ; hex(TWIC_MASTER_STATUS) ; ", &B" ; bin(TWIC_MASTER_STATUS)
print #2, " - i2c.2 state" ; i2c2_scl ; ", " ; i2c2_sda ; ", &H" ; hex(TWIE_MASTER_STATUS) ; ", &B" ; bin(TWIE_MASTER_STATUS)

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
print #2, " - i2c.1 reset"
      TWIC_MASTER_CTRLA.3=0

      for i = 1 to 8
         reset i2c1_scl
         waitus 1
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         set i2c1_scl
         waitus 1
      next

      portc.0=1
      TWIC_MASTER_CTRLA.3=1

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
print #2, " - i2c.2 reset"
      TWIE_MASTER_CTRLA.3=0

      for i = 1 to 8
         reset i2c2_scl
         waitus 1
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         set i2c2_scl
         waitus 1
      next

      porte.0=1
      TWIE_MASTER_CTRLA.3=1

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
print #2, " - i2c.1 state" ; i2c1_scl ; ", " ; i2c1_sda ; ", &H" ; hex(TWIC_MASTER_STATUS) ; ", &B" ; bin(TWIC_MASTER_STATUS)
print #2, " - i2c.2 state" ; i2c2_scl ; ", " ; i2c2_sda ; ", &H" ; hex(TWIE_MASTER_STATUS) ; ", &B" ; bin(TWIE_MASTER_STATUS)

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
print #2, " - i2c.1 scan: " ;
for i = 2 to 254 step 2
   i2cstart #5
   i2cwbyte i , #5
   if err = 0 then print #2, hex(i) ; " " ;
   i2cstop #5
   err = 0
next
print #2, ""

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
print #2, " - i2c.2 scan: " ;
for i = 2 to 254 step 2
   i2cstart #6
   i2cwbyte i , #6
   if err = 0 then print #2, hex(i) ; " " ;
   i2cstop #6
   err = 0
next
print #2, ""

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
print #2, " - peripheral_devices_reset.1: " ; peripheral_devices_reset1
print #2, " - peripheral_devices_reset.2: " ; peripheral_devices_reset2

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
print #2, " * end"

'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
'print #2, " * main loop"
'do
'loop
 


Result 2.0.7.9, device "&H68" on "twie" and the program can run endless :
Code:

  * start
 - peripheral_devices_reset.1: 0
 - peripheral_devices_reset.2: 0
 > set peripheral_devices_reset.1
 > set peripheral_devices_reset.2
 - i2c.1 scan: 68 98 A0 A8 E0
 - i2c.2 scan: 20 30 68 A0
 - i2c.1 state1, 1, &H11, &B00010001
 - i2c.2 state1, 1, &H11, &B00010001
 - i2c.1 reset
 - i2c.2 reset
 - i2c.1 state1, 1, &H10, &B00010000
 - i2c.2 state1, 1, &H10, &B00010000
 - i2c.1 scan: 68 98 A0 A8 E0
 - i2c.2 scan: 20 30 68 A0
 - peripheral_devices_reset.1: 1
 - peripheral_devices_reset.2: 1
 * end
 * start
 - peripheral_devices_reset.1: 0
 - peripheral_devices_reset.2: 0
 > set peripheral_devices_reset.1
 > set peripheral_devices_reset.2
 - i2c.1 scan: 68 98 A0 A8 E0
 - i2c.2 scan: 20 30 68 A0
 - i2c.1 state1, 1, &H11, &B00010001
 - i2c.2 state1, 1, &H11, &B00010001
 - i2c.1 reset
 - i2c.2 reset
 - i2c.1 state1, 1, &H10, &B00010000
 - i2c.2 state1, 1, &H10, &B00010000
 - i2c.1 scan: 68 98 A0 A8 E0
 - i2c.2 scan: 20 30 68 A0
 - peripheral_devices_reset.1: 1
 - peripheral_devices_reset.2: 1
 * end
...
 * start
 - peripheral_devices_reset.1: 0
 - peripheral_devices_reset.2: 0
 > set peripheral_devices_reset.1
 > set peripheral_devices_reset.2
 - i2c.1 scan: 68 98 A0 A8 E0
 - i2c.2 scan: 20 30 68 A0
 - i2c.1 state1, 1, &H11, &B00010001
 - i2c.2 state1, 1, &H11, &B00010001
 - i2c.1 reset
 - i2c.2 reset
 - i2c.1 state1, 1, &H10, &B00010000
 - i2c.2 state1, 1, &H10, &B00010000
 - i2c.1 scan: 68 98 A0 A8 E0
 - i2c.2 scan: 20 30 68 A0
 - peripheral_devices_reset.1: 1
 - peripheral_devices_reset.2: 1
 * end
 


Result 2.0.8.1, device "&H68" will show on the first run, but then it's gone, the "twie" state is completely different :
Code:

 * start
 - peripheral_devices_reset.1: 0
 - peripheral_devices_reset.2: 0
 > set peripheral_devices_reset.1
 > set peripheral_devices_reset.2
 - i2c.1 scan: 68 98 A0 A8 E0
 - i2c.2 scan: 20 30 68 A0
 - i2c.1 state1, 1, &H11, &B00010001
 - i2c.2 state1, 1, &H72, &B01110010
 - i2c.1 reset
 - i2c.2 reset
 - i2c.1 state1, 1, &H10, &B00010000
 - i2c.2 state1, 1, &H70, &B01110000
 - i2c.1 scan: 68 98 A0 A8 E0
 - i2c.2 scan: 20 30 68 A0
 - peripheral_devices_reset.1: 1
 - peripheral_devices_reset.2: 1
 * end
 * start
 - peripheral_devices_reset.1: 0
 - peripheral_devices_reset.2: 0
 > set peripheral_devices_reset.1
 > set peripheral_devices_reset.2
 - i2c.1 scan: 68 98 A0 A8 E0
 - i2c.2 scan: 20 30 A0
 - i2c.1 state1, 1, &H11, &B00010001
 - i2c.2 state1, 1, &H72, &B01110010
 - i2c.1 reset
 - i2c.2 reset
 - i2c.1 state1, 1, &H10, &B00010000
 - i2c.2 state1, 1, &H70, &B01110000
 - i2c.1 scan: 68 98 A0 A8 E0
 - i2c.2 scan: 20 30 A0
 - peripheral_devices_reset.1: 1
 - peripheral_devices_reset.2: 1
 * end
...
 * start
 - peripheral_devices_reset.1: 0
 - peripheral_devices_reset.2: 0
 > set peripheral_devices_reset.1
 > set peripheral_devices_reset.2
 - i2c.1 scan: 68 98 A0 A8 E0
 - i2c.2 scan: 20 30 A0
 - i2c.1 state1, 1, &H11, &B00010001
 - i2c.2 state1, 1, &H72, &B01110010
 - i2c.1 reset
 - i2c.2 reset
 - i2c.1 state1, 1, &H10, &B00010000
 - i2c.2 state1, 1, &H70, &B01110000
 - i2c.1 scan: 68 98 A0 A8 E0
 - i2c.2 scan: 20 30 A0
 - peripheral_devices_reset.1: 1
 - peripheral_devices_reset.2: 1
 * end
 


Best Regards Mark
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5071
Location: Holland

blank.gif
PostPosted: Tue Jan 08, 2019 9:55 pm    Post subject: Reply with quote

I had a look at the output and the cause is a BUG in i2cstop : it loads the TWIC address instead of the (in this case) TWIE address.
I do not know yet how that is possible but that is next. At first glance no change was made to the code.

To workaround this add a sub to your code :
Code:
declare sub twiestop()

Sub Twiestop()
  Loadadr Twie_ctrl , Z
  !call _i2c_stop
End Sub
 

Instead of calling i2cstop #6 you call twiestop

_________________
Mark
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5071
Location: Holland

blank.gif
PostPosted: Tue Jan 08, 2019 10:19 pm    Post subject: Reply with quote

I am glad that you took time to supply the test code. Without it i could not have found the problem.
And apologies to you and all for the bug. I have many conditional code switches and one was wrong. This caused i2cstop to always take the i2cstop path, which results in the default i2cstop for xmega : twic.
This also means that i2cstop for twid,twie and twif will not work and need a similar workaround as posted earlier.

_________________
Mark
Back to top
View user's profile Visit poster's website
MDuprau

Bascom Member



Joined: 13 Oct 2012
Posts: 30

PostPosted: Tue Jan 08, 2019 10:22 pm    Post subject: Reply with quote

Hello,

i can wait with the update to 2.0.8.1, to find out whats going on cant take so long.

Maybe a old crossfix from "xm256A3U.def" :

[2.0.7.9, CONFIG-TWIE:OPTION1 points to TWIC]
Code:

[CONFIG-TWIC]
SECTION=I2C\TWIC
OPTIONCOUNT=1
OPTION1=TWIC
OPTION1VALUE=[1-400000]

[CONFIG-TWIE]
SECTION=I2C\TWIE
OPTIONCOUNT=1
OPTION1=TWIC
OPTION1VALUE=[1-400000]
 


[2.0.8.1]
Code:

[CONFIG-TWIC]
SECTION=I2C\TWIC
OPTIONCOUNT=1
OPTION1=TWIC
OPTION1VALUE=[1-400000]

[CONFIG-TWIE]
SECTION=I2C\TWIE
OPTIONCOUNT=1
OPTION1=TWIE
OPTION1VALUE=[1-400000]
 


Best Regards Mark
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Unsupported versions All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
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