hat schon irgend wer Infos zum MIRF24port mit der uses uMIRF24. Ich bring das mit dem angegebenen Treiber und dem xmega xmega32A4 zum laufen. Ich dachte das hier jemand Infos liefern kann. Es sieht so aus, dass der Sender nicht arbeitet. An der Hardware kann es nicht liegen. Bisher habe ich einige Probleme mit den xmega auch im bereich der I2C Treiber.
Code
program ModRF_01M;
{$WG} {global Warnings on}
Device = xmega32A4, VCC=3.3;
Define_Fuses
COMport = USB;
ProgMode = PDI;
Import SysTick, TickTimer, SysLEDblink, MIRF24port;
Import WatchDog, SerPortD0, SerPortD1, SPI_C;
From System Import LongWord, LongInt, Float, PIDs;
From SysLEDblink Import LEDmessage, FlashOnce; // this is optional
Define
// The XMegas don't provide any Oscillator fuses.
// So the application must setup the desired values
OSCtype = int32MHz, PLLmul=4, prescB=1, prescC=1;
SysTick = 10; {msec}
StackSize = $0064, iData;
FrameSize = $0064, iData;
WatchDog = msec2000; {2048msec}
MIRF24port = SPI_C, PortC, 4, 3, 2; // standard SPI port SS, CE, IRQ;
SPIorderC = MSB;
SPImodeC = 1;
SPIprescC = 1;//, double; // double speed = optional
SPI_SSC = PortC, 4;
// SPI_SSC = none;
SysLedBlink = mSec25; {SysTicks}
SysLedBlink0 = PortR, 0, low;
SysLedBlink1 = PortE, 0, high;
// RS232
SerPortD1 = 115200;
RxBufferD1 = 30, iData;
TxBufferD1 = 30, iData;
// RS485
SerPortD0 = 115200, Stop1, timeout; {Baud, StopBits|Parity}
SerCtrlD0 = PortD, 1, positive; {XMega control line for RS485 driver}
RxBufferD0 = 30, iData;
TxBufferD0 = 30, iData;
TickTimer = Timer_C0; // use Timer_C0 and no PortPin
uses uMIRF24;
Implementation
{--------------------------------------------------------------}
{ Type Declarations }
type
{$IDATA}
{--------------------------------------------------------------}
{ Const Declarations }
Const
LEDOn : Boolean = False;
LEDOff : Boolean = True;
{--------------------------------------------------------------}
{ Var Declarations }
Var
Timer1 : SysTimer;
Err : Byte;
uMIR_Aktiv : Boolean;
uMIR_Mode : tMRFpkt;
rxCnt : byte;
rxBuff : array[0..31] of byte;
rxString[@rxBuff] : string[30];
txBuff : array[0..31] of byte;
txString[@rxBuff] : string[30];
CE[@PortC,3] : Bit; { CE }
{$IDATA}
{--------------------------------------------------------------}
{ functions }
{--------------------------------------------------------------}
{ Initialisieren der CPU }
{--------------------------------------------------------------}
Procedure InitPorts;
Begin
DDRA := DDRB AND %00000000; // Output=1 Input=0
DDRB := DDRB AND %11111110; // Output=1 Input=0
DDRC := DDRC OR %11011010; // Output=1 Input=0
// DDRE := DDRE Or %00000001; // Output=1 Input=0
PortE := $01;
DDRR := DDRR Or %00000001; // Output=1 Input=0
End;
{--------------------------------------------------------------}
{--------------------------------------------------------------}
Procedure InitSystem;
Begin
InitPorts;
TickTimerTime(10000); // 10000usec = 10msec
TickTimerStart;
FlushBuffer (RxBufferD0);
FlushBuffer (TxBufferD0);
FlushBuffer (RxBufferD1);
FlushBuffer (TxBufferD1);
mrfSetChan(mrfChan3, false);
mrfSetPower(mrfdBm0);
mrfSetLocalAddr(0);
mrfSetRetryMax(10);
mrfSetRetryTimeOut(40); // 5x 250usec -> 1.25msec
mrfSetRFspeed(mrfRF2000);
CE:=True;
uMIR_Aktiv:=mrfInit;
CE:=False;
// wenn der MIRF24 Treiber/Modul vorhanden ist
if mrfInit then
SetSerEnable(UsartD0, True);
WriteLn(SerOutD0,'uMIR_Aktiv');
SetSerEnable(UsartD0, False);
EndIf;
End;
{--------------------------------------------------------------}
{ Main Program }
{$IDATA}
begin
EnableInts($87);
InitSystem;
SysLEDflashOnce(0);
SetSerEnable(UsartD0, True);
WriteLn(SerOutD0,'Mod_nRF start');
SetSysTimer(Timer1,100);
loop
// wenn der MIRF24 Treiber/Modul vorhanden ist
if mrfInit then
txString:='Test_1';
WriteLn(SerOutD0,txString);
CE:=True;
If mrfTxPacket(2, @txBuff, 6, True)=False Then
Case MRFgetState Of
EndCase;
WriteLn(SerOutD0,'mrfTxPacket=False');
Else
WriteLn(SerOutD0,'mrfTxPacket=True');
EndIf;
CE:=False;
mDelay(500);
txString:='Test_2';
WriteLn(SerOutD0,txString);
CE:=True;
If mrfTxPacket(2, @txBuff,6, False)=False Then
WriteLn(SerOutD0,'mrfTxPacket=False');
Else
WriteLn(SerOutD0,'mrfTxPacket=True');
EndIf;
CE:=False;
mDelay(500);
Else
WriteLn(SerOutD0,'uMIR_Aktiv=False');
EndIf;
SysLEDflashOnce(0);
mDelay(100);
endloop;
end.