ATmega64-16AU Serport2 Not work

Peter KWS
Benutzer
Avatar
Gender: n/a
Age: 40
Posts: 18
Registered: 11 / 2011
Subject:

ATmega64-16AU Serport2 Not work

 · 
Posted: 29.11.2011 - 23:35  ·  #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
Gender:
Location: Frankfurt Main / Germany
Posts: 1697
Registered: 02 / 2003
Subject:

Re: ATmega64-16AU Serport2 Not work

 · 
Posted: 30.11.2011 - 00:10  ·  #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
Gender: n/a
Age: 40
Posts: 18
Registered: 11 / 2011
Subject:

Re: ATmega64-16AU Serport2 Not work

 · 
Posted: 30.11.2011 - 00:22  ·  #3
Yess, Thank you very much Gunter, now is all ok :) SerPort2 work fine :) Good idea!! Bye :)
Gunter
Administrator
Avatar
Gender:
Location: Frankfurt Main / Germany
Posts: 1697
Registered: 02 / 2003
Subject:

Re: ATmega64-16AU Serport2 Not work

 · 
Posted: 30.11.2011 - 00:26  ·  #4
Quote
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
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: 15 · Cache Hits: 14   73   87 · Page-Gen-Time: 0.030286s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI