Das ist mein Loader.
Code
// BOOTLOADER FÜR ELS Rev 6 XMEGA
program XMega_BootAppSer;
{$NOSHADOW}
{ $WG} {global Warnings off}
Device = XMega256A3U, VCC = 3.3;
{$BOOTAPPLICATION} // $20000
define_fuses
Override_Fuses;
COMport = USB;
ProgMode = PDI;
FuseBits0 = [];
FuseBits1 = [];
FuseBits2 = [BootRst]; // mandatory !!
FuseBits5 = [BODACT0, BODLEVEL1, BODLEVEL0, EESAVE];// BODLEVEL 101 LEVEL 2 2.0 Volt!
FuseBits4 = [RSTDISBL];
import SysTick, SerPortD1, FlashLoader, BeepPort;
from System import Traps;
define
OSCtype = int32MHz, // CPU=32MHz
PLLmul = 4,
prescB = 1, // PeripherX4=32MHz
prescC = 1;
StackSize = $0100, iData;
FrameSize = $0100, iData;
MaxTraps = 2; // 2..16
SysTick = 10;
SerPortD1 = 256000, parNone; // Download device
RxBufferD1 = 150, iData;
TxBufferD1 = 50, iData;
BeepPort = PortR, 0;
implementation
{$USERROW}
const
CHARGE: byte = 1;
{$IDATA}
{--------------------------------------------------------------}
{ Type Declarations }
{--------------------------------------------------------------}
{ Const Declarations }
const
// this constant must be the same as in the Main app
DownLoaderID : word = $1000; // mandatory constant
{$IDATA}
var
i: byte;
key_RIGHT[@PINA, 0]: bit;
LED1[@PortA, 5] : bit;
LED2[@PortA, 4] : bit;
{--------------------------------------------------------------}
{ functions }
procedure FlashLoaderInit; // mandatory
begin
end;
function FlashLoaderRecv: byte; // mandatory
begin
return(SerInpD1);
end;
procedure FlashLoaderTransm(arg: byte); // mandatory
begin
SerOutD1(arg);
end;
// mandatory
procedure FlashLoaderExit;
begin
if Application_Valid then
EEprom[EEpromEnd]:= $00; // validate application for Boot usage
BeepChirpH(3);
endif;
mdelay(100);
HardwareReset; // restart with a jump into the Boot
end;
{--------------------------------------------------------------}
{ Main Program }
{$IDATA}
begin
DDRA:= %00110000; // 0= input, 1= Output
PIN0CTRLA:= %00011000; // Pullup KRIGHT
PIN1CTRLA:= %00011000; // Pullup KUP
PIN2CTRLA:= %00011000; // Pullup KDOWN
PIN3CTRLA:= %00011000; // Pullup KLEFT
// Pin4=led1
// Pin5=led2
PIN6CTRLA:= %00000000; // No Pull, ENCA
PIN7CTRLA:= %00000000; // No Pull, ENCB
if key_RIGHT then
incl(LED2);
Application_Startup;
endif;
EnableInts($87);
incl(LED1);
loop
FlashDownLoader;
endloop;
end XMega_BootAppSer.