Anyone have experience interfacing to TI's CC1101 series of radios via SPI?
Anyone have experience interfacing to TI's CC1101 series of radios via SPI?
Hi Zebryk,
I'm working on a project similar to yours so perhaps we can learn something from each other. My radio is a KFR transceiver from D6 Labs, and is based the SX1272 chip from Semtech. It uses SPI communications. I've searched this Forum and found the following thread which discusses SPI issues among other things:
http://www.picbasic.co.uk/forum/show...ghlight=rfm22b
Forum member Paul has posted some code at post #5 which I have found useful as a guide. Based on this info I have put together some code to just test the send and receive function of the Pic to the KFR radio via SPI. Unfortunately, it is not working as yet ... I'm still trouble shooting. If you are interested I can post my code ... it is very simple.
I found this whilst looking for someting else.....
Maybe of use ? :
http://www.squirrel-labs-files.co.uk...z-RF1100SE.zip
BR
Andy
Thanks Andy,
Quite interesting but vast.
Can you share any background?
Hi
Sorry I haven't used the radio .... I was looking for something else and remembered your post here....So posted link!
BR
Andy
I used the 900MHz Anaren radio module that uses that chip and what a mental workout, but got it working.
I found an article in Nutsvolts that helped me structure the sequence of events in order to get it working right. The code is in C+ but was able to decipher what to do.
Attached is a copy of the article.
Texas Instruments SmartRF Studio also helped with more insight. It provides all the info on every parameter that sucker uses.
Let me know if this is relevant and need some sample code. I used it with a PIC16F685 and PBP 2.5 or so back then.
Louie
LinkMTech-
I was trying to use Microchip's 900MHz radio, but it whipped me - never got it to work (posted elsewhere on this forum) and now am looking for another radio.
Would you post what you did so I can get a head start on this? I just want to xmit 3 byte packet...... The idea is a 1 to many design.
Thanks in advance,
Steve
"If we knew what we were doing, it wouldn't be called research"
- Albert Einstein
Sure!
The A1101R09A module allows you to TX/RX data straight through using one of the GDO pins or using the SPI buffer depending on configuration. I found that using the SPI mode had better bandwidth efficiency with higher throughput.
I never finished upgrading to its full potential because there's still a lot thats over my head but have plenty of code to get you started.
I'll go through my files and dig up where I left off.
Louie
Okay, I found the test code for the demo.
It's old code probably using PBP2.5 so you'll need to adjust to your flavoring.
I used this to just test the transmitter but it can be configured for RX too.
Here's the schematic to go with that code:Code:'**************************************************************** '* Name : Anaren Air Module.PBP '* Date : 10/30/2010 '* Version : PIC12F683 on protoPCB, 1.0 '* Notes : This routine uses DEBUGIN from PC to send SPI data to control '* the Anaren Transceiver Module A1101R09*. The idea is to first load all '* pertinent information to configure the module then using DEBUGIN to '* control the transmitter ON/OFF, mod or w/o mod, baud rate and PA level. '* '**************************************************************** @ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF OSCCON = %01110001 ' Osc 8Mhz ANSEL = %00000000 ' A/D turned OFF ADCON0 = %10000000 ' Right justified and OFF CMCON0 = 7 ' Analog comparators off GPIO = %00001001 ' TRISIO = %00001001 ' DEFINE OSC 8 INCLUDE "modedefs.bas" ' DEBUG Defines for Transmitter DEFINE DEBUG_REG GPIO DEFINE DEBUG_BIT 1 ' GPIO 1 Pin#6 DEFINE DEBUG_BAUD 19200 DEFINE DEBUG_MODE 1 ' 1 = inverted, 0 = true ' DEBUG Defines for Receiver DEFINE DEBUGIN_REG GPIO DEFINE DEBUGIN_BIT 3 ' GPIO 3 Pin#4 DEFINE DEBUGIN_BAUD 19200 DEFINE DEBUGIN_MODE 1 ' 1 = inverted, 0 = true ' Alias pin assignments SCLK VAR GPIO.4 ' SPI bus clock on Pin#3 MOSI VAR GPIO.5 ' SPI bus data to device on Pin#2 MISO VAR GPIO.0 ' SPI bus data from module on Pin#7 _CSN VAR GPIO.2 ' SPI bus select on Pin#5 ' Alias SPI variables Address VAR BYTE Add VAR BYTE mode var BYTE register VAR BYTE cnt VAR BYTE value VAR BYTE ' Setup outputs _CSN = 1 ' S_SEL set to idle HIGH Add = $0 Value = 0 mode = $0 PAUSE 500 '///////////////////////////////////////////////////////////////////////// ' Register setup ' This routine loads all the register values derived from the TI Smart RF ' calculations. Load all mode values here. Takes 19.6ms to load ' Highlights: (08:$32, Async transparent mode), (0A:$48, CH#72, 916.396MHz) ' (15:$43, Dev = 39KHz) '///////////////////////////////////////////////////////////////////////// FOR Address = 0 to $2E SELECT CASE Address CASE 0: mode = $0B : CASE 1: mode = $2E : CASE 2: mode = $0C CASE 3: mode = $47 : CASE 4: mode = $D3 : CASE 5: mode = $91 CASE 6: mode = $3D : CASE 7: mode = $04 : CASE 8: mode = $22 CASE 9: mode = $00 : CASE $0A: mode = $48 : CASE $0B: mode = $08 CASE $0C: mode = $00 : CASE $0D: mode = $22 : CASE $0E: mode = $B1 CASE $0F: mode = $3B : CASE $10: mode = $CA : CASE $11: mode = $83 CASE $12: mode = $90 : CASE $13: mode = $22 : CASE $14: mode = $F8 CASE $15: mode = $43 : CASE $16: mode = $07 : CASE $17: mode = $30 CASE $18: mode = $18 : CASE $19: mode = $16 : CASE $1A: mode = $6C CASE $1B: mode = $43 : CASE $1C: mode = $40 : CASE $1D: mode = $91 CASE $1E: mode = $87 : CASE $1F: mode = $6B : CASE $20: mode = $F8 CASE $21: mode = $56 : CASE $22: mode = $10 : CASE $23: mode = $E9 CASE $24: mode = $2A : CASE $25: mode = $00 : CASE $26: mode = $1F CASE $27: mode = $41 : CASE $28: mode = $00 : CASE $29: mode = $59 CASE $2A: mode = $7F : CASE $2B: mode = $3F : CASE $2C: mode = $81 CASE $2D: mode = $35 : CASE $2E: mode = $09 END SELECT _CSN = 0 ' Enable Select bit GOSUB chip_status ' Allow data transfer when device ready SHIFTOUT MOSI,SCLK,1,[Address,mode] _CSN = 1 ' Disable Select bit NEXT Address ' Additional setups _CSN = 0 ' Enable Select bit GOSUB chip_status ' Allow data transfer when device ready SHIFTOUT MOSI,SCLK,1,[$7E,$8E] ' Set PA output to 0dBm SHIFTOUT MOSI,SCLK,1,[$33] ' Calibrate synthesizer then turn OFF _CSN = 1 ' Disable Select bit '///////////////////////////////////////////////////////////////////////// ' Main test program loop ' Use DEBUG to monitor on Realterm set to Port 4 and 19200,8,1,N on laptop ' USB port nearest DVD player. ' Command type examples: ' Turn ON TX: 0 53 0 ' Turn OFF TX: 0 54 0 ' Change CH#: 4 n 0 ' n=CH# 0~130 ' Change mod type: 1 16 202 ' 38.4KB 1st entry ' 1 17 131 ' 38.4KB 2nd entry ' ' Change PA level: 1 126 3 ' -30dBm ' 1 126 14 ' -20dBm ' 1 126 30 ' -15dBm ' 1 126 39 ' -10dBm ' 1 126 142 ' 0dBm ' 1 126 205 ' +5dBm ' 1 126 199 ' +7dBm ' 1 126 192 ' +10dBm '///////////////////////////////////////////////////////////////////////// Main: DEBUGIN 10000, Main,[add,Address,mode] ' Loop here until PC data RX'd. SELECT CASE Add CASE 0: GOTO single CASE 1: GOTO burst CASE 2: GOTO multi CASE 3: GOTO CH_change CASE 4: GOTO CH_change_mod END SELECT single: ' Sends only the Address value to the module. Takes 173us. _CSN = 0 ' Enable Select bit GOSUB chip_status ' Allow data transfer when device ready SHIFTOUT MOSI,SCLK,1,[Address] _CSN = 1 ' Disable Select bit DEBUG "Address value sent to module ",DEC Address,13,10 GOTO Main burst: ' Sends Address and mode values together to the module. Takes 340us _CSN = 0 ' Enable Select bit GOSUB chip_status ' Allow data transfer when device ready SHIFTOUT MOSI,SCLK,1,[Address,mode] _CSN = 1 ' Disable Select bit DEBUG "Address and Mode value sent to module ",DEC Address, " and ", DEC mode,13,10 GOTO Main multi: ' Sends Address and mode values sequentually to the module _CSN = 0 ' Enable Select bit GOSUB chip_status ' Allow data transfer when device ready SHIFTOUT MOSI,SCLK,1,[Address] _CSN = 1 ' Disable Select bit PAUSEUS 50 _CSN = 0 ' Enable Select bit WHILE MISO : WEND ' Allow data transfer when device ready SHIFTOUT MOSI,SCLK,1,[mode] _CSN = 1 ' Disable Select bit GOTO Main CH_change: ' Changes channel based on channel number input. Takes 1.19ms _CSN = 0 ' Enable Select bit GOSUB chip_status ' Allow data transfer when device ready SHIFTOUT MOSI,SCLK,1,[$36] ' Turn OFF TX SHIFTOUT MOSI,SCLK,1,[$12,$B0] ' Setup for no modulation SHIFTOUT MOSI,SCLK,1,[$0A,Address] ' Enter CH# SHIFTOUT MOSI,SCLK,1,[$31] ' SFSTXON, Cal synth and stby SHIFTOUT MOSI,SCLK,1,[$35] ' STX, turn ON transmitter _CSN = 1 ' Disable Select bit GOTO Main CH_change_mod: ' Changes channel and enables modulation. Takes 1.19ms _CSN = 0 ' Enable Select bit GOSUB chip_status ' Allow data transfer when device ready SHIFTOUT MOSI,SCLK,1,[$36] ' Turn OFF TX SHIFTOUT MOSI,SCLK,1,[$12,$90] ' Setup for modulation SHIFTOUT MOSI,SCLK,1,[$0A,Address] ' Enter CH# SHIFTOUT MOSI,SCLK,1,[$31] ' SFSTXON, Cal synth and stby SHIFTOUT MOSI,SCLK,1,[$35] ' STX, turn ON transmitter _CSN = 1 ' Disable Select bit GOTO Main chip_status: ' Wait until module ready to accept new data IF MISO = 1 THEN chip_status RETURN END
Module demo.pdf
This code was used on the keyfob using the PIC16F685. I was able to send a 22 byte message error free using the TX FIFO register. I think the module configuration is the same as above but don't have my hand written notes handy.
Code:main: m = m+1 GOSUB TX_FIFO Grn = 1 GOSUB transmit ' Takes 176us to send command Grn = 0 WHILE !GDO0: WEND ' Goes High after Preamble and Sync Word sent WHILE GDO0 = 1 ' and takes 2ms before sending packet. Grn = 1 ' Wait for TX to complete WEND ' 1 byte packet takes 233us to TX Grn = 0 GOSUB Clear_TX_FIFO PAUSE 100 GOTO main '========================== Data packet loading ======================== ' Burst data into TX FIFO register $3F by adding $40 TX_FIFO: _CSN = 0 ' Enable Select bit GOSUB chip_status ' Allow data transfer when device ready SHIFTOUT MOSI,SCLK,1,[$7F,$01,$02,$03,$04,$05,$06,$07,$08,$09,$0A,_ $0B,$0C,$0D,$0E,$0F,$10,$11,$12,$13,$14,$15,$16,$17,m] _CSN = 1 ' Disable Select bit RETURN '======================== Transmit routine ============================== transmit: _CSN = 0 ' Enable Select bit GOSUB chip_status ' Allow data transfer when device ready SHIFTOUT MOSI,SCLK,1,[$35] ' STX, turn ON transmitter _CSN = 1 ' Disable Select bit RETURN Clear_TX_FIFO: _CSN = 0 ' Enable Select bit GOSUB chip_status ' Allow data transfer when device ready SHIFTOUT MOSI,SCLK,1,[$3B] ' Flush out TX FIFO buffer _CSN = 1 ' Disable Select bit RETURN
Louie
Thanks Louie-
I plan on using the A1101R09A00GM module, is that what you used? It should arrive tomorrow.
My idea is more of using these modules as a transmitter and receiver application even though they are transceivers.
How did you use the RSSI or did you? I would like to be able to see which transmitter is closest to which receiver. and then establish a link, send a few bytes and that pretty much it. More of a sensor transmission....
Does this sound reasonable given your experience?
-Steve
"If we knew what we were doing, it wouldn't be called research"
- Albert Einstein
I have successfully used the RSSI from a receiver for TPM testing at work while designing an AGC circuit for a TPM Transmitter program. just remember that if using ASK transmissions you will need a fast A/D and you should gather enough data during a xmission to see the PEAK level. I have used this to program an 8 bit attenuator at the frontend of the receiver using successive approximation routine I wrote. That way each of the test Transmitters have the same received signal strength to the receiver for timing verification purposes. It is NOT as critical for the A/D if you are using FSK mode. I wish I could share more but I wrote the software for the company I work for... Good Luck...
Dave Purola,
N8NTA
EN82fn
You're welcome Steve,
Yup, that's one of them. I also used the other where you have to connect an external antenna.
The device has a digital RSSI register that can be read continuously. I never got to it in that last product where I was going to use for "clear channel search".
The code provided sets the transmitter modulation to 4 level FSK at +-39KHz deviation if I recall.
It can be configured to be a transmitter only, receiver only or switch between the two modes, it's up to you.
Your application is feasible, keeping air time management in mind to avoid transmission collisions, just like you would anyways with direct data connections.
Here's 1 data sheet on the RSSI you can go through. I couldn't upload the other because of it's size but can get it here.
Dave- What is TPM?
Louie
thanks Guys-
My modules are due in tomorrow, however, I have to go out of town on business so it will have to wait a bit longer darn it.
I really can't wait to see this work!
The MRF module never did work nor could I find ANYONE who saif they got it to work in packets!
Thanks again. Will keep you posted on progress - and code.
Regards to All.
"If we knew what we were doing, it wouldn't be called research"
- Albert Einstein
Yeah, I bought a pair of them MRF's too but only ended up staring at them cuz they look cool.
Louie
Yup. I should have my radios in waiting for me Monday. Then I can see about playing with them.......
"If we knew what we were doing, it wouldn't be called research"
- Albert Einstein
Steve,
I remembered unsuccessfully trying to solder rework wire to the module's pads only to damage it.
Do you make your PCBs?
I have some older revision PCBs with footprints for these module if you're interested. No strings, just willing to help.
Louie
I would REALLY appreciate that. I just looked at my radio development 'kits' (2) and all I got was the module with an antenna! It looks as if these plug into something else........
So, it looks like I am going to make a cheap proto pcb....... I use Eagle, what do you use?
Regards,
Steve
"If we knew what we were doing, it wouldn't be called research"
- Albert Einstein
I use Express PCB and Pad2Pad for my boards.
Which kits did you order?
PM me your address so I can mail you some PCBs.
Last edited by LinkMTech; - 6th July 2015 at 16:00. Reason: clarity
Louie
I ordered the CC1101EMK868-915 from Mouser. Then just today I ordered the SOC-BB also from Mouser.
The SOC-BB should (?) allow me to plug in the radio modules, power via battery which is kinda weird, but will allow me to SPI-communicate to the radio.
I have been told the TI will work for me to do my coding, then move to the Anaren part which has the TI part and is FCC licensed.
I don't think I could use the Pad2Pad file to create my foot print for the radio, I will double check.
Thanks for the offer on the boards, but as I will need to generate my own with the radio, I think I should just muddle through and do it myself.
I would like to know more about the RSSI and actually how to use the data, were you successful in doing this? The other post made it sound as if going FSK would be easier.
"If we knew what we were doing, it wouldn't be called research"
- Albert Einstein
I didn't get to the RSSI function but didn't see it a problem since it means reading a register during the RX mode. The level range is pretty good and linear.
The RSSI value is available to be read from a register when the module is in RX mode. This value varies with the other transmitters signal strength reaching it. The value will of course be digital but have a minimum to maximum value. There will always be some value there due to noise or other transmitters on same channel.
Here's a simplified example of using it in your app, keeping the timing between TX and RX from module to module in mind:
Base changes to TX mode and sends addressed query message to sensor
Base changes back to RX mode and begins reading RSSI register
Addressed sensor receives message and changes to TX and sends an ACK of some sort
Sensor module reverts back to RX mode
Base monitoring the RSSI records the value during valid message from sensor.
Since you want to "talk" to the closest sensor, query the others in the same way then choose the one with the highest RSSI value after comparing all RSSI's.
This is a general description of the signal strength. There are other factors that will cause it to vary like interference, fading, etc. but it's a pretty good indicator to work with.
Louie
Thanks Louie. What proc did you use with you radios?
"If we knew what we were doing, it wouldn't be called research"
- Albert Einstein
Hmmm, I never used PM so I have no experience with attaching PDFs. Try changing the extension name.
Did you try the other email address I sent?
"If we knew what we were doing, it wouldn't be called research"
- Albert Einstein
Used a PIC16F677 or a PIC16F685 in my devices.
PMs and PDF sent...
Louie
Bookmarks