OK, TABSoft -
I'm having trouble either sending or receiving data.... Thought I had this puppy trained.
Registers are:
Code:
' RF_Init_Values[0] = $28 'Standby mode, 915-928 MHz, VTune by inductors, ENABLE R1/P1/S1
RF_Init_Values[0] = $68 'RECEIVE mode, 915-928 MHz, VTune by inductors, ENABLE R1/P1/S1
RF_Init_Values[1] = $8C 'FSK, max IF gain, Packet Mode
RF_Init_Values[2] = $01 '200KHz Freq Dev
RF_Init_Values[3] = $63 '2KBps
RF_Init_Values[4] = $0C 'for OOK mode, not apliable
RF_Init_Values[5] = $03 '16Bytes FIFO, 3 Bytes threshold FIFO transmit interrupt
RF_Init_Values[6] = $77 '915MHz R1 Reg
RF_Init_Values[7] = $64 '915MHz P1 Reg
RF_Init_Values[8] = $32 '915MHz S1 Reg
RF_Init_Values[9] = $74 '920MHz R2 Reg
RF_Init_Values[10] = $62 '920MHz P2 Reg
RF_Init_Values[11] = $32 '920MHz S2 Reg
RF_Init_Values[12] = $38 'config mode for OOK, not apliable
RF_Init_Values[13] = $0D 'RCV:IRQ0=payload ready + IRQ1=CRC OK
'TX: mostly normal
RF_Init_Values[14] = $19 '00011001
RF_Init_Values[15] = $00 '
RF_Init_Values[16] = $A3 'default filters config
RF_Init_Values[17] = $38 'default filters config
RF_Init_Values[18] = $30 'sync word ON, 24bits, 0 errors tolerance
RF_Init_Values[19] = $00 'reserved reg
RF_Init_Values[20] = $00 'RSII status read register, 0.5dB / bit
RF_Init_Values[21] = $00 'OOK config reg
RF_Init_Values[22] = $53 '"S" 1st byte of sync word
RF_Init_Values[23] = $43 '"C" 2nd byte of sync word
RF_Init_Values[24] = $53 '"S" 3rd byte of sync word - my initials!
RF_Init_Values[25] = $00 '
RF_Init_Values[26] = $70 'utoff fcy = 200KHz, output power = 13dBm 0b000
RF_Init_Values[27] = $BC 'clk out by default 427KHz
RF_Init_Values[28] = $02 '3 bytes payload
RF_Init_Values[29] = $01 'initial MAC ADDRESS, only for test
RF_Init_Values[30] = $5E 'Fix Packet Lenght, 3 bytes preamble, whitening ON, CRC ON, Node ADDR|0x00|0xFF filtering
RF_Init_Values[31] = $00 'FIFO autocreal enable if CRC fails, Write to FIFO in stby mode for (i = 0; i < 32; i++)
And test code is:
Code:
'MRF initialization here
debug "@ MRF init", 10
MRFConfigSel=0 'Select the chip
'Going to try using shiftout before using hardware SPI
for i=0 to 31 'Sets up the index var for data
MRFaddr=(i << 1) 'Shifts address 1 bit to left, automatically gets start,write, and stop bits
SHIFTOUT SDO, SCLK, 1,[MRFaddr,RF_Init_Values(i)] 'send data to register
debug "Addr=",bin8 MRFaddr," Value=",hex2 RF_Init_Values[i],13
next i
MRFConfigSel=1 'Deselect the chip
'Try to read back some registers as a test to see if they were written correctly
MRFConfigSel=0 'Select the chip
for i = 0 to 7 'Sets up address to read
MRFaddr=((i << 1) | $40) 'Shifts left 1 bit, sets $40 bit, automatically gets start, READ, and stop bits
SHIFTOUT SDO, SCLK, 1,[MRFaddr] 'Address to read
SHIFTIN SDI, SCLK, 0,[MRFSPIdata] 'Get data from reg
debug "MRF Config data: i=", dec1 i, " Register ", bin8 MRFaddr, " Data=", hex2 MRFSPIdata,13
next i
'Try sending something
debug "Try sending 3 bytes",13
XMIT_EN: i=0 'Register of interest
MRFaddr=(i<<1) 'Gets register address format
MRFConfigSel=0 'Select the chip
SHIFTOUT SDO, SCLK, 1,[MRFaddr,$88] 'send data, TRANSMIT, 915-928, Vtune by tank caps, Enable R1 P1 S1
MRFConfigSel=1 'Deselect the chip
XMIT: MRFDataSel=0
SHIFTOUT SDO, SCLK, 1,[$A1]
MRFDataSel=1
MRFDataSel=0
SHIFTOUT SDO, SCLK, 1,[$B1]
MRFDataSel=1
MRFDataSel=0
SHIFTOUT SDO, SCLK, 1,[$C1]
MRFDataSel=1
RCV: i=0 'Register of interest
MRFaddr=(i<<1) 'Gets register address format
MRFConfigSel=0 'Select the chip
SHIFTOUT SDO, SCLK, 1,[MRFaddr,$68] 'send data, RECEIVE, 915-928, Vtune by tank caps, Enable R1 P1 S1
MRFConfigSel=1 'Deselect the chip
Wait4Pkt: If MRFIrq0=1 and MRFIrq1=1 then
MRFDataSel=0 'Select chip cuz we have a packet ready and CRC is good
SHIFTIN SDI, SCLK, 0,[data3,data2,data1] 'Get data from reg
debug "MRF payload: Data3=",hex2 data3," Data2=",hex2 data2," Data1=",hex2 data1,13
endif
goto Wait4Pkt
But after init and the confirming of the 1st few registers as before - it just sits there like a plum.
I seem to have the config registers working, but now the FIFO seems to be playing hard.
My interrupts aren't being set either due to not transmitting or receiving correctly.
My payload is only 3 bytes, and the smallest the FIFO can be is 16 bytes.
Not much for me to scope on this...... MC's DS is not too clear but you honed in on a failure I had, do you see anything wrong?
This is my 1st RF project so I may have the registers all screwed up in order to work.... not too much out there as a guide.
Regards.
Bookmarks