ATmega64-16AU Serport2 Not work

Peter KWS
Benutzer
Avatar
Geschlecht: keine Angabe
Alter: 42
Beiträge: 18
Dabei seit: 11 / 2011
Betreff:

ATmega64-16AU Serport2 Not work

 · 
Gepostet: 29.11.2011 - 23:35 Uhr  ·  #1
Hallo all, pleas i need help with mein project with ATMEGA64. I need read and write data in Serport1 and Serport2.
I write basic testing program for reading and send data.
Serport1 work good (No problem) but Serport2 is absolutly 'death' :( .
I dont know why!
I triyng change the MCU for new and Serport2 still not work :(
Max232 on serport2 is ok and testing with serport1 and work good. Where is problem?
Any idea?
here is my basic code...
----------------------------------------------------------------------------------------------------------------------------
program test_serial;

{ $BOOTRST $07000} {Reset Jump to $07000}
{$NOSHADOW}
{ $WG} {global Warnings off}

Device = mega64, VCC=5;

Import SysTick, SerPort, SerPort2;

From System Import ;

Define
ProcClock = 16000000; {Hertz}
SysTick = 10; {msec}
StackSize = $0064, iData;
FrameSize = $0064, iData;
SerPort = 19200, Stop1; {Baud, StopBits|Parity}
RxBuffer = 16, iData;
TxBuffer = 16, iData;
SerPort2 = 19200, Stop1; {Baud, StopBits|Parity}
RxBuffer2 = 16, iData;
TxBuffer2 = 16, iData;

Implementation

{$IDATA}

{--------------------------------------------------------------}
{ Type Declarations }

type


{--------------------------------------------------------------}
{ Const Declarations }

{--------------------------------------------------------------}
{ Var Declarations }
{$IDATA}
var
Led_TX [@PortD, 5] : Bit;
Led_RX [@PortD, 4] : Bit;
ZnakIn : Array [0..20] of byte;
InCykl : byte;
Led_Rxcount : Integer;
Led_Txcount : Integer;
{--------------------------------------------------------------}
{ functions }

interrupt RXRDY;
begin
ZnakIn[InCykl] := SerInp;
if ZnakIn[0] = $31 then
InCykl := InCykl + 1;
else
InCykl := 0;
endif;
end;

procedure InitPorts;
begin
DDRD := %00110000;
end InitPorts;

{--------------------------------------------------------------}
{ Main Program }
{$IDATA}

begin

InitPorts;
EnableInts;
loop
if InCykl >= 18 then
InCykl := 0;
ZnakIn[0] := 0;
Led_Rx := True;
Write( SerOut, 'Test Port 1' );
Write( SerOut2, 'Test Port 2' );
FlushBuffer ( TxBuffer );
FlushBuffer ( TxBuffer2 );
Led_Tx := True;
endif;

If (Led_rx = true) then Inc(Led_Rxcount); else Led_Rxcount := 0; endif;
If (Led_Rxcount >= 50) then Led_Rx := false; Led_Rxcount := 0; endif;
If (Led_tx = true) then Inc(Led_Txcount); else Led_Txcount := 0; endif;
If (Led_Txcount >= 50) then Led_Tx := false; Led_Txcount := 0; endif;
mdelay(1);
endloop;
end test_serial.

Thanks for your time.
Gunter
Administrator
Avatar
Geschlecht:
Herkunft: Frankfurt Main / Germany
Beiträge: 1697
Dabei seit: 02 / 2003
Betreff:

Re: ATmega64-16AU Serport2 Not work

 · 
Gepostet: 30.11.2011 - 00:10 Uhr  ·  #2
Hi Peter and welcome here!

You must disable (set to binary "1") the M103C fuse (Mega103 compatibility mode) to archieve the full control of the Mega64 functions. This fuse is active by factory default!

hth
Gunter
Peter KWS
Benutzer
Avatar
Geschlecht: keine Angabe
Alter: 42
Beiträge: 18
Dabei seit: 11 / 2011
Betreff:

Re: ATmega64-16AU Serport2 Not work

 · 
Gepostet: 30.11.2011 - 00:22 Uhr  ·  #3
Yess, Thank you very much Gunter, now is all ok :) SerPort2 work fine :) Good idea!! Bye :)
Gunter
Administrator
Avatar
Geschlecht:
Herkunft: Frankfurt Main / Germany
Beiträge: 1697
Dabei seit: 02 / 2003
Betreff:

Re: ATmega64-16AU Serport2 Not work

 · 
Gepostet: 30.11.2011 - 00:26 Uhr  ·  #4
Zitat
Good idea!!
no problem. This is one of the 3 or 4 most famous problems:
besides enabled JTAG and different SPI programming pins on some Megas.

Gunter
Gewählte Zitate für Mehrfachzitierung:   0

Registrierte in diesem Topic

Aktuell kein registrierter in diesem Bereich

Die Statistik zeigt, wer in den letzten 5 Minuten online war. Erneuerung alle 90 Sekunden.
MySQL Queries: 15 · Cache Hits: 14   73   87 · Page-Gen-Time: 0.059887s · Speichernutzung: 2 MB · GZIP: ein · Viewport: SMXL-HiDPI