I2CPort und SerPortXy bei xMega

  • 1
  • 2
  • Page 1 of 2
tramike
 
Avatar
 
Subject:

I2CPort und SerPortXy bei xMega

 · 
Posted: 03.05.2012 - 22:11  ·  #1
Hallo allerseits,

wenn ich versuche, bei einem xMega das I2CPort und die SerPortXy auf demselben I/O-Port (aber natürlich nicht auf denselben Pins) zu nutzen, dann stört das I2CPort die Pins der SerPortXy.

Code

Program I2CTest;
  Device = XMega256A3U, VCC=3.3;
Define_Fuses
  NoteBook   = B;
  COMport    = USB;
  LockBits0  = [];
  FuseBits0  = [];
  FuseBits1  = [];
  FuseBits2  = [];
Import SysTick, FlashWrite, WatchDog, Heap, XMegaSupport, I2CPort,
SerPortE0, SerPortF0, SerPortC0, SerPortC1, SerPortD0, ADC_A;

From System Import Float, Processes, Tasks, Pipes, PIDs;
From SysTick Import SystemTime16;

Define
  OSCtype        = extXTAL=16000000, PLLmul=8, prescA=1, prescB=2, prescC=1;  
  StackSize      = $0800, iData;
  FrameSize      = $0800, iData;
  SysTick        = 10;                {msec}
  
  I2CPort        = PortC;
  I2Cdat         = 0;
  I2Cclk         = 1;

  SerPortC0      = 57600, Stop1, timeout;
  RxBufferC0     = 250, iData;
  TxBufferC0     = 250, iData;
  
Implementation

{$IDATA}
Const
  I2CAddrIOExp: byte = $27;

Var
  I2CVal: Byte;

Begin

  // IO-Expander Prog     
  I2COut(I2CAddrIOExp,$00,$F7);
  
  Loop
    If I2Cstat(I2CAddrIOExp) Then
      I2COut(I2CAddrIOExp,$00);
      I2CInp(I2CAddrIOExp,I2CVal);
       WriteLn(SerOutC0, 'I2C Dir: '+ByteToHex(I2CVal));
      I2COut(I2CAddrIOExp,$06);
      I2CInp(I2CAddrIOExp,I2CVal);
       WriteLn(SerOutC0, 'I2C Pullups: '+ByteToHex(I2CVal));
      I2COut(I2CAddrIOExp,$09);
      I2CInp(I2CAddrIOExp,I2CVal);
       WriteLn(SerOutC0, 'I2C In: '+ByteToHex(I2CVal));
    Else
      WriteLn(SerOutC0,'I2C Not OK');
    EndIf;
    Sleep(Self, 50);
  Endloop;
End I2CTest;


Das Program sendet bei den I2Cxxx-Befehlen Müll auf die seriellen Leitungen.
Hardwaremässig sieht es fast so aus, wie wenn eine Lötbrucke zwischen dem I2C und SerPort Pin besteht. Aber das ist klar nicht der Fall. Es muss softwareseitig bei der Port-Ansteuerung in den I2C-Prozeduren ein Fehler sein.

...oder ich versuche etwas, das ohnehin nicht zulässig ist?

Hat jemand Erfahung mit der Nutzung von I2C und SerPort auf demselben I/O-Port eines xMegas?

Danke und Gruss,
Mike
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1374
Registered: 03 / 2005
Subject:

Re: I2CPort und SerPortXy bei xMega

 · 
Posted: 04.05.2012 - 10:06  ·  #2
I have seen something similar in ATMega's where an ESD damaged chip had adjacent port pins shorted out. Don't know if this is relevant.
tramike
 
Avatar
 
Subject:

Re: I2CPort und SerPortXy bei xMega

 · 
Posted: 05.05.2012 - 16:11  ·  #3
Thank you for the hint, but it is rather unlikely, for the following reasons:
- the serial port does not influence the I2C, just the I2C disturbes the serial ports.
- the whole batch of 50 xMegas must have been affected. This would be possible, but is unlikely.
- if I manipulate the pins of the I2C directly, they don't affect the serial lines.

Thank you for any hint,
Mike
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: I2CPort und SerPortXy bei xMega

 · 
Posted: 06.05.2012 - 15:59  ·  #4
Hallo Mike,

ich muss das untersuchen.
Aber Sie sollten ein funktionierendes Programm zur Verfügung stellen das das Problem aufzeigt.
Das obige Programm lässt sich wegen vielen Define Problemen nicht compilieren! :sick:

rolf
tramike
 
Avatar
 
Subject:

Re: I2CPort und SerPortXy bei xMega

 · 
Posted: 07.05.2012 - 20:21  ·  #5
Hallo Rolf,

sorry, ich hatte den Compiler nicht dabei, als ich den Post schrieb. (...Ferien...)
Dafür jetzt eine noch weiter reduzierte Variante, welche das Problem dokumentiert:

Code

Program I2CTest;
Device = XMega256A3U, VCC=3.3;

Import SysTick, Heap, XMegaSupport, I2CPort, SerPortC0;

From System Import Float, Processes, Tasks, Pipes;

Define
  OSCtype        = extXTAL=16000000, PLLmul=8, prescA=1, prescB=2, prescC=1;

  StackSize      = $0800, iData;
  FrameSize      = $0800, iData;
  SysTick        = 10;                {msec}


  I2CPort        = PortC;
  I2Cdat         = 0;
  I2Cclk         = 1;

  SerPortC0      = 57600, Stop1, timeout;
  RxBufferC0     = 250, iData;
  TxBufferC0     = 250, iData;

  Heap           = iData;
  Scheduler      = 10, 10, iData;
  TaskStack      = $0020, iData;
  TaskFrame      = $0010;
  
Implementation
{$IDATA}
Const
  I2CAddrIOExp: byte = $27;
Begin
  Start_Processes($87);
  Loop
    WriteLn(SerOutC0, 'Test!!');
    I2COut(I2CAddrIOExp,$00);
  Endloop;
End I2CTest.


Resultat auf der SerC0: Abwechselnd "Test!!" und Müll.

Danke und Gruss,
Mike
pvs-deck
PowerUser
Avatar
Gender:
Age: 53
Homepage: pvs-deck.de
Posts: 1341
Registered: 02 / 2009
Subject:

Re: I2CPort und SerPortXy bei xMega

 · 
Posted: 10.05.2012 - 15:23  ·  #6
Hallo Mike,
Quote by tramike

Resultat auf der SerC0: Abwechselnd "Test!!" und Müll.

Danke und Gruss,
Mike


So ein Problem habe ich Heute auch mit einem XMEGA256A3, ich benutze genau wie Du
"WriteLn(SerOutC0, '............')", "I2COut(......)" usw.

Ich habe immer am Ende der WriteLN SerOut Schrott stehen :(

@rolf: Gibt es da schon eine Lösung?

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

Re: I2CPort und SerPortXy bei xMega

 · 
Posted: 10.05.2012 - 20:12  ·  #7
@all,
leider hat mich eine ziemliche Grippe erwischt. Ich komme erst die nächsten Tage dazu. :lupe:

rolf
tramike
 
Avatar
 
Subject:

Re: I2CPort und SerPortXy bei xMega

 · 
Posted: 11.05.2012 - 13:45  ·  #8
@Thorsten: danke, bin froh um Deinen Beitrag!
@Rolf: Ich wünsche Dir von Herzen gute Besserung!

Gruss,
Mike
  • 1
  • 2
  • Page 1 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   137   151 · Page-Gen-Time: 0.021432s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI