There is a bug with toggle as shown in the following code. Amazingly, this occurs with a MEGA1280 but not with a MEGA128!
the assembler for ExecDebug is
As you can see the IN and EOR lines are missing. As I say, if I change the processor to a MEGA128 the lines are there!
Code
program Bug;
Device = mega1280, VCC=5;
Import SysTick, LCDPort;
From System Import;
Define
ProcClock = 7372800; {Hertz}
SysTick = 10; {msec}
StackSize = 50, iData;
FrameSize = 50, iData;
LCDtype = 44780; {66712}
LCDport = PortA; {Port Address}
LCDRows = 2; {2-lined display}
LCDcolumns = 16; {16-character display}
uses
;
Implementation
{$IDATA}
const
type
{--------------------------------------------------------------}
{ Var Declarations }
var
DebugLED [@PORTB, 2] : bit;
{--------------------------------------------------------------}
{ functions }
procedure ExecDebug;
begin
Toggle( DebugLED );
end;
{ Main Program }
{$IDATA}
begin
EnableInts;
loop
ExecDebug;
endloop;
end Bug.
Device = mega1280, VCC=5;
Import SysTick, LCDPort;
From System Import;
Define
ProcClock = 7372800; {Hertz}
SysTick = 10; {msec}
StackSize = 50, iData;
FrameSize = 50, iData;
LCDtype = 44780; {66712}
LCDport = PortA; {Port Address}
LCDRows = 2; {2-lined display}
LCDcolumns = 16; {16-character display}
uses
;
Implementation
{$IDATA}
const
type
{--------------------------------------------------------------}
{ Var Declarations }
var
DebugLED [@PORTB, 2] : bit;
{--------------------------------------------------------------}
{ functions }
procedure ExecDebug;
begin
Toggle( DebugLED );
end;
{ Main Program }
{$IDATA}
begin
EnableInts;
loop
ExecDebug;
endloop;
end Bug.
the assembler for ExecDebug is
Code
.FUNC ExecDebug, 00027h, 00020h
Bug.ExecDebug:
.RETURNS 0
.BLOCK 40
.LINE 41
LDI _ACCB, 004h
OUT 023h, _ACCB
.ENDBLOCK 42
Bug.ExecDebug_X:
.LINE 42
.BRANCH 19
RET
.ENDFUNC 42
Bug.ExecDebug:
.RETURNS 0
.BLOCK 40
.LINE 41
LDI _ACCB, 004h
OUT 023h, _ACCB
.ENDBLOCK 42
Bug.ExecDebug_X:
.LINE 42
.BRANCH 19
RET
.ENDFUNC 42
As you can see the IN and EOR lines are missing. As I say, if I change the processor to a MEGA128 the lines are there!