Ok so it is working... As far as I have set all the initialize registers as per the datasheet example with the exception of the 10MHz clock line, and a 4.5V low battery detect...
I can now see the clock line change to 10MHz
Working code is below...
Code:
define osc 4
' Define LCD registers and bits
DEFINE LCD_DREG PORTD 'LCD addressing
DEFINE LCD_DBIT 4 'L1 = $80
DEFINE LCD_RSREG PORTD 'L2 = $C0
DEFINE LCD_RSBIT 1 'L3 = $94
DEFINE LCD_EREG PORTD 'L4 = $D4
DEFINE LCD_EBIT 3
lcdrw var portd.2
nSEL var portb.4
SDI var portb.5
SCK var portb.6
SDO var portb.7
dout var word
n VAR BYTE
nn VAR byte
cmd var bit[16]
TRISB = %00000100
low lcdrw
nSEL = 1
SDI = 1
SCK = 0
pause 500
lcdout $fe,1
Start:
lcdout $fe,$80,"RFM12B Initialize"
pause 500
gosub Init
goto start
'Subroutines
WriteCMD:
for n = 15 to 0 step -1
CMD[n] = dout.15
dout = dout << 1
next n
SCK = 0
nSEL = 0
for nn = 15 to 0 step -1
if cmd[nn] = 1 then
gosub write1
else
gosub write0
endif
next nn
sck = 0
nSel = 1
pause 500
return
Write0:
SDI = 0 : SCK = 0 : pauseus 16 : SCK = 1 : pauseus 1 : return
Write1:
SDI = 1 : SCK = 0 : pauseus 16 : SCK = 1 : pauseus 1 : return
Init:
dout = $80D8 'enable register, 433MHz, 12.5pf
gosub Writecmd
dout = $8208 'Turn on crystal, !PA
gosub Writecmd
dout = $A640
gosub Writecmd
dout = $C647
gosub Writecmd
dout = $94C0 'VDI, FAST, 134kHz
gosub Writecmd
dout = $C2AC
gosub Writecmd
dout = $CA80
gosub Writecmd
dout = $CA83 'FIFO8, SYNC
gosub Writecmd
dout = $C49B
gosub Writecmd
dout = $9850 '!mp, 9810=30kHz, Max Out
gosub Writecmd
dout = $E000 'Not Used
gosub Writecmd
dout = $C80E 'Not Used
gosub Writecmd
dout = $C0F7 '10MHZ, 4.5V
gosub Writecmd
Return
This has been very painful for me - having not touched RF before, so I'm hopeing that someone else gets some use out of my hair-pulling...
There is much more to do, I haven't even got round to sending data yet, and I haven't worked out how you are meant to run the pic on the 1MHz clock, then set it to 10Mhz, and have it all work fine. At the moment I have it running on an external 4Mhz crystal.
When I get a good working TX and RX bit of code I will start a new post with as much info as I can work out...
Thanks again to all the people that helped me get this far!
Cheers
Dave
Bookmarks