Back to cooking with gas........
Code as was before:
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
And the debug output:
Code:
@ MRF init
Addr=00000000 Value=28
Addr=00000010 Value=8C
Addr=00000100 Value=01
Addr=00000110 Value=63
Addr=00001000 Value=0C
Addr=00001010 Value=03
Addr=00001100 Value=77
Addr=00001110 Value=64
Addr=00010000 Value=32
Addr=00010010 Value=74
Addr=00010100 Value=62
Addr=00010110 Value=32
Addr=00011000 Value=38
Addr=00011010 Value=00
Addr=00011100 Value=19
Addr=00011110 Value=00
Addr=00100000 Value=A3
Addr=00100010 Value=38
Addr=00100100 Value=30
Addr=00100110 Value=00
Addr=00101000 Value=00
Addr=00101010 Value=00
Addr=00101100 Value=53
Addr=00101110 Value=59
Addr=00110000 Value=44
Addr=00110010 Value=00
Addr=00110100 Value=70
Addr=00110110 Value=BC
Addr=00111000 Value=02
Addr=00111010 Value=01
Addr=00111100 Value=5E
Addr=00111110 Value=00
MRF Config data: i=0 Register 01000000 Data=28
MRF Config data: i=1 Register 01000010 Data=8C
MRF Config data: i=2 Register 01000100 Data=01
MRF Config data: i=3 Register 01000110 Data=63
MRF Config data: i=4 Register 01001000 Data=0C
MRF Config data: i=5 Register 01001010 Data=03
MRF Config data: i=6 Register 01001100 Data=77
MRF Config data: i=7 Register 01001110 Data=64
Which matches perfectly.
I did scope the data in, out and noticed the pulses were not right at all.
Then double-check the schematic and board to the datasheets - cuz, you know sometimes there is a mistake.........
I appreciate your help, your going back to basics post was done after I had done it so we think alike - I am just DUMB!
Your help in finding the correct way to address the registers was of immense help, I just missed that one completely.
I'm off to the races, well, off to get the code for a wireless smart sensor system for the house.......
When working, will post code to help others.
Regards.
Bookmarks