mega8 und TWI = Problem

  • 1
  • 2
  • Page 2 of 2
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1373
Registered: 03 / 2005
Subject:

Re: mega8 und TWI = Problem

 · 
Posted: 31.01.2011 - 17:51  ·  #9
OK, I see. So the identical program without the loop works, but with it does not?

Do you use the optimiser? If so does it make any difference if you do not use it?

Regards

Merlin.
AVR-Bastler
 
Avatar
 
Subject:

Re: mega8 und TWI = Problem

 · 
Posted: 02.02.2011 - 17:33  ·  #10
Hi Merlin,

the program with the loop works. But only if i do not use the TWIstat in the loop. Only before the loop. Now i found out, when i use the TWIstat in the loop, only the first TWIout makes problems.
If a second TWIout follows later in the loop, i can use the data send by the second TWIout.
So it is a problem between the TWIstat and the first TWIout (when i use both together in the loop).

I use the optimiser and i have to check, where i can disable it to see if it makes any differences.

Regards

AVR-Bastler
Gunter
Administrator
Avatar
Gender:
Location: Frankfurt Main / Germany
Posts: 1697
Registered: 02 / 2003
Subject:

Re: mega8 und TWI = Problem

 · 
Posted: 02.02.2011 - 19:57  ·  #11
Hi,

Code
loop
  if TWIstat(TWIaddr) = true then               //erzeugt das Fehlverhalten
    mDelay(10);
    if TWIout(TWIaddr, $01, data) = true then
      PortB := %00000001;
    else PortB := %00000000;
    endif;
  endif;
endloop;

ist vielleicht bei 1. Aufruf TWIstat einige Zeit = false?
Dann erzeugt die Loop ohne Pause TWIstat Anfragen.
Evtl würde

loop
mDelay(10);
if ...

helfen?

Ich weiss, dass sich die Atmel TWI Implementierung bei den Megas leicht
aufhängt, wenn auf den TWI sehr schnell zugegeriffen wird.

Gruß
Gunter
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1373
Registered: 03 / 2005
Subject:

Re: mega8 und TWI = Problem

 · 
Posted: 02.02.2011 - 22:04  ·  #12
Hi AVR-Bastler.

To compile without optimising is the 'hammer' button (Ctrl-F9). With optimising is usually the 'wall' button (Ctrl+Shft+F9).

Regards

Merlin.
AVR-Bastler
 
Avatar
 
Subject:

Re: mega8 und TWI = Problem

 · 
Posted: 03.02.2011 - 15:54  ·  #13
Hi Merlin and Gunter,

@Merlin
Thanks for this information. But it looks like it makes no difference if i use the optimiser or not.

@Gunter
Du hattest Recht, TWIstat ist tatsächlich für einige Momente false, was ich mit dem mDelay(10) beheben konnte.
Allerdings hat das keine Verbesserung für den ersten TWIout Aufruf gebracht. Das Verhalten ist unverändert.

Regards
AVR_Bastler
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: mega8 und TWI = Problem

 · 
Posted: 03.02.2011 - 18:37  ·  #14
Hallo Bastler,

ein AVR I2C Slave kann nicht wie ein normaler Hardware Slave behandelt werden. Der dahinterstehende AVR im Slave arbeitet im Interrupt und kann u.U. nicht in Lichtgeschwindigkeit antworten. Ein high speed loop vom Master bringt den Slave mit Sicherheit ins Schleudern.

rolf
  • 1
  • 2
  • Page 2 of 2
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 8 · Cache Hits: 14   104   118 · Page-Gen-Time: 0.01522s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI