das mit dem DEMO für den ST7565R auf dem XMEGA-A3BU Xplained Demoboard haut bei mir nicht hin. Habe aber keine Ahnung wo mein Fehler liegt. :aerger
Code
program xMega;
Device = xmega256A3BU, VCC=3.3;
{ $BOOTRST $20000} {Reset Jump to $20000}
Import SysTick, SPI_D, LCDGraphic;
From LCDGraphic Import CharSet; {block CharSet, pixels}
From System Import ;
Define
// XMega USB must use the internal 32MHz OSC. So the system must use the 2MHz OSC
// Wegen USB Port
OSCtype = int32MHz,
PLLmul=4,
prescB=1,
prescC=1;
SysTick = 10,User; {msec}
StackSize = $0080, iData;
FrameSize = $0080, iData;
// use the Column mode controller ST7565R with SPI interface
SPIorderD = LSB;
SPImodeD = 0;
SPIprescD = 1;
SPI_SSD = PortD, 0;
LCDGraphic = 128, 64, 8; {x-pix, y-pix, accesswidth}
LCDgraphMode = column, iData; // column mode
DefCharSet = 'Graphchars.pchr'; {FileName}
GViewports = 1, iData; {logical ViewPorts, scalings}
TGraphStr = 16; {Graphic Text String Length}
Implementation
{$IDATA}
const
// definitions for 2 bitmap types
BmpSize8x8 : byte = (8*8 div 8) + 2;
BmpSize16x32 : byte = (16*32 div 8) + 2;
{--------------------------------------------------------------}
{ Type Declarations }
type
// we need a few array types where we can insert the bitmaps
tBMP8 = array[1..BmpSize8x8] of byte;
tArrows = array[0..3, 1..BmpSize8x8] of byte;
tChips = array[0..15, 1..BmpSize16x32] of byte;
{--------------------------------------------------------------}
const
// constant which hold contain the bitmaps
Arrows : tArrows = 'Arr_N.pbmp', 'Arr_W.pbmp', 'Arr_S.pbmp', 'Arr_E.pbmp';
Folder8 : tBMP8 = 'Folder8.pbmp';
ChipsV : tChips = 'ChipV0.pbmp', 'ChipV1.pbmp', 'ChipV2.pbmp', 'ChipV3.pbmp',
'ChipV4.pbmp', 'ChipV5.pbmp', 'ChipV6.pbmp', 'ChipV7.pbmp',
'ChipV8.pbmp', 'ChipV9.pbmp', 'ChipV10.pbmp', 'ChipV11.pbmp',
'ChipV12.pbmp', 'ChipV13.pbmp', 'ChipV14.pbmp', 'ChipV15.pbmp';
ChipsH : tChips = 'ChipH0.pbmp', 'ChipH1.pbmp', 'ChipH2.pbmp', 'ChipH3.pbmp',
'ChipH4.pbmp', 'ChipH5.pbmp', 'ChipH6.pbmp', 'ChipH7.pbmp',
'ChipH8.pbmp', 'ChipH9.pbmp', 'ChipH10.pbmp', 'ChipH11.pbmp',
'ChipH12.pbmp', 'ChipH13.pbmp', 'ChipH14.pbmp', 'ChipH15.pbmp';
{--------------------------------------------------------------}
{ Const Declarations }
{--------------------------------------------------------------}
{ Var Declarations }
Var
LCDcmd[@PortE, 3] : bit;
bb, idx, pwm, co : byte;
i : integer;
ch : char;
{$IDATA}
{ functions }
{$D-}
UserDevice GraphIOS(cmd : byte; arg : byte);
begin
(* Display Refresh with "GraphIOS" *)
(* cmd = 0 arg = rowaddr set rowaddr to arg *)
(* cmd = 1 arg = pixels write data byte *)
if cmd = 0 then
PortF.3:=True;
LCDcmd:= 0;
// set page addr
SPIoutByteD($B0+arg);
// set column address
SPIoutByteD($10);
SPIoutByteD($00);
else
PortF.3:=False;
// data out
LCDcmd:= 1;
SPIoutByteD(arg);
endif;
end;
{$D+}
procedure InitPorts;
begin
DDRR := DDRR Or %00000011; // Output=1 Input=0
DDRD := DDRD Or %00000001; // Output=1 Input=0
DDRE := DDRE Or %00010000; // Output=1 Input=0
DDRF := DDRF Or %00001000; // Output=1 Input=0
DDRA := DDRA Or %00001000; // Output=1 Input=0
end;
procedure InitGraph;
begin
// SetSPIorderD(true);
// SetSPIclkPhaD(0);
// SetSPIdoubleSpeedD(true);
// LCD command pin A0 // Graph Init
// write init values to controller
LCDcmd:= 0;
SPIoutByteD($40); // display start line = 0
SPIoutByteD($A1); // Display config, ADC reverse,
SPIoutByteD($C0); // Normal COM0..63
SPIoutByteD($A6); // Display normal
SPIoutByteD($A2); // set BIAS 1/9
SPIoutByteD($2F); // Booster and Regulator on
SPIoutByteD($F8); // Booster Ratio 4x
SPIoutByteD($00); // Booster Ratio 4x
SPIoutByteD($27); // Vo voltage regulator
SPIoutByteD($81); // electronic volume mode
SPIoutByteD($12); // electronic volume set
SPIoutByteD($AC); // no indicator
SPIoutByteD($00); // no indicator
SPIoutByteD($AF); // Display on
gclrscr(0);
gdisprefresh;
end;
procedure LCDreset;
begin
PortA.3:=False;
mDelay(1);
PortA.3:=True;
mDelay(100);
LCDcmd:= 0;
SPIoutByteD($E2); // soft reset
mDelay(10);
PortR.1:=True;
end;
procedure SetContrast(ctr : byte);
begin
LCDcmd:= 0;
SPIoutByteD($81); // electronic volume mode = contrast cmd
SPIoutByteD(ctr); // contrast set 0..63
end;
{--------------------------------------------------------------}
{ Main Program }
{$IDATA}
begin
InitPorts;
InitGraph;
LCDreset;
EnableInts($87);
PortE.4:=True;
SetContrast(30);
gDrawRect(20, 6, 104, 56, $FF);
gDrawRect(0, 0, 127, 63, $AA);
gdisprefresh;
mdelay(100);
gSetTextJustify(alHorCenter, alVertBottom);
gSetTextBkGnd(bkTransp);
gSetTextMode(wmSetPix);
gDrawString(35, 53, 1, 1, TxtRot0, 'Test');
gSetTextMode(wmXorPix);
gDrawString(60, 28, 2, 2, TxtRot0, 'E-LAB');
gDrawString(60, 40, 1, 1, TxtRot0, 'Computers');
gDrawString(125, 31, 2, 2, TxtRot90, 'AVRco');
gdisprefresh;
mdelay(10);
loop
PortR.0:=False;
mDelay(5);
PortR.0:=True;
mDelay(200);
endloop;
end xMega.