Hallo Gunter,
anscheinend mache ich da anscheinend einen fehler. mit dem demo sollte doch der mastr ein telegramm an den slave senden. bei mir kommt aber nichts an. ich bekomme im slave nur ein mrfPKTnone. der master sollte auch mit der poll-led antworten. keine ahnung wo der fehler sitzen siollte. kannst du nicht den fehler finden ?
gruß
walter
Code
program WLAN01_M;
{$NOSHADOW}
{ $WG} {global Warnings off}
Device = mega32, VCC=5;
Define_Fuses
Override_Fuses;
COMport = USB;
LockBits0 = [];
FuseBits0 = [BODEN, BODLEVEL];
FuseBits1 = [CKOPT];
FuseBits2 = [];
ProgMode = SPI;
Import SysTick, ADCPort, I2Cport, LANport;
Import RTclock;
Import MIRF24port;
From System Import LongWord, LongInt, Float;
Define
ProcClock = 16000000; {Hertz}
SysTick = 10; {msec}
StackSize = $0064, iData;
FrameSize = $0064, iData;
ADCchans = 1, iData;
ADCpresc = 128;
I2Cport = PortD;
I2Cdat = 7;
I2Cclk = 6;
MIRF24port = SPI_Soft, PortC, 2, 3, 4, 1, 0, 5;
// SCK, MOSI, MISO, SS, CE, IRQ
LANport = SerPort;
LANctrl = PortD, 4;
LANbaud = 38400;
LANmode = Slave;
LANadr = 8; {8/16 BIT}
LANframe = 8, iData; {Frame size in bytes}
LANcheck = ChkSum8; {ChkSum8, ChkSum16, CRC16}
RTClock = iData, Time; {Time, DateTime}
uses uMIRF24;
Implementation
{$IDATA}
{--------------------------------------------------------------}
{ Type Declarations }
{--------------------------------------------------------------}
{ Const Declarations }
{--------------------------------------------------------------}
{ Var Declarations }
Var
Poll [@PortB,0]:Bit;
txBuff : array[0..31] of byte;
txString[@txBuff] : string[30];
rxBuff : array[0..31] of byte;
rxString[@rxBuff] : string[30];
rxCnt : byte;
{--------------------------------------------------------------}
{ functions }
Procedure InitSystem;
Begin
DDRB := DDRB Or %00000111; // Output=1 Input=0
mrfSetChan(mrfChan9, false);
mrfSetPower(mrfdBm0);
mrfSetLocalAddr(0);
mrfSetRetryMax(10);
mrfSetRetryTimeOut(4); // 5x 250usec -> 1.25msec
mrfSetRFspeed(mrfRF2000);
Poll:=False;
mDelay(250);
End;
{--------------------------------------------------------------}
{ Main Program }
{$IDATA}
begin
EnableInts;
InitSystem;
if mrfInit then
Loop
Poll:=True;
txString:= 'Hello';
if mrfTxPacket(2, @txBuff, 5, False) then
Poll:=False;
mDelay(100);
EndIf;
mDelay(2000);
endloop;
endif;
end.
Code
program WLAN01_S;
{$NOSHADOW}
{ $WG} {global Warnings off}
Device = mega32, VCC=5;
Define_Fuses
Override_Fuses;
COMport = USB;
LockBits0 = [];
FuseBits0 = [BODEN, BODLEVEL];
FuseBits1 = [CKOPT];
FuseBits2 = [];
ProgMode = SPI;
Import SysTick, ADCPort, I2Cport, LANport;
Import RTclock;
Import MIRF24port;
From System Import LongWord, LongInt, Float;
Define
ProcClock = 16000000; {Hertz}
SysTick = 10; {msec}
StackSize = $0064, iData;
FrameSize = $0064, iData;
ADCchans = 1, iData;
ADCpresc = 128;
I2Cport = PortD;
I2Cdat = 7;
I2Cclk = 6;
MIRF24port = SPI_Soft, PortC, 2, 3, 4, 1, 0, 5;
// SCK, MOSI, MISO, SS, CE, IRQ
LANport = SerPort;
LANctrl = PortD, 4;
LANbaud = 38400;
LANmode = Slave;
LANadr = 8; {8/16 BIT}
LANframe = 8, iData; {Frame size in bytes}
LANcheck = ChkSum8; {ChkSum8, ChkSum16, CRC16}
RTClock = iData, Time; {Time, DateTime}
uses uMIRF24;
Implementation
{$IDATA}
{--------------------------------------------------------------}
{ Type Declarations }
{--------------------------------------------------------------}
{ Const Declarations }
{--------------------------------------------------------------}
{ Var Declarations }
Var
Poll [@PortB,0]:Bit;
txBuff : array[0..31] of byte;
txString[@txBuff] : string[30];
rxBuff : array[0..31] of byte;
rxString[@rxBuff] : string[30];
rxCnt : byte;
{--------------------------------------------------------------}
{ functions }
Procedure InitSystem;
Begin
DDRB := DDRB Or %00000111; // Output=1 Input=0
mrfSetChan(mrfChan9, false);
mrfSetPower(mrfdBm0);
mrfSetLocalAddr(2);
mrfSetRetryMax(10);
mrfSetRetryTimeOut(4); // 5x 250usec -> 1.25msec
mrfSetRFspeed(mrfRF2000);
Poll:=False;
mDelay(250);
Poll:=True;
End;
{--------------------------------------------------------------}
{ Main Program }
{$IDATA}
begin
EnableInts;
InitSystem;
Loop
Poll:=True;
if mrfInit then
repeat
until mrfGetRxType <> mrfPKTnone;
case mrfRxPacket(@rxBuff, 250, rxCnt) of
mrfPKTdata : Poll:=False; mDelay(250);Poll:=True;|
mrfPKTnone : Poll:=False; mDelay(10); Poll:=True;|
mrfPKTbcast : Poll:=False; mDelay(100); Poll:=True;|
EndCase;
EndIf;
endloop;
end.