Hey, I'm gonna send data with CC1101 in asynchronous serial mode. In TI SmartRF Studio I generated register's values for the 433.92MHz and ASK/OOK modulation
radio.writeSingleByte(defs.IOCFG2,0x0B) #GDO2 Output Pin Configuration radio.writeSingleByte(defs.IOCFG0,0x0C) #GDO0 Output Pin Configuration radio.writeSingleByte(defs.FIFOTHR,0x47) #RX FIFO and TX FIFO Thresholds radio.writeSingleByte(defs.PKTCTRL0,0x32)#Packet Automation Control radio.writeSingleByte(defs.FSCTRL1,0x06) #Frequency Synthesizer Control radio.writeSingleByte(defs.FREQ2,0x10) #Frequency Control Word, High Byte radio.writeSingleByte(defs.FREQ1,0xB0) #Frequency Control Word, Middle Byte radio.writeSingleByte(defs.FREQ0,0x71) #Frequency Control Word, Low Byte radio.writeSingleByte(defs.MDMCFG4,0xF5) #Modem Configuration radio.writeSingleByte(defs.MDMCFG3,0x83) #Modem Configuration radio.writeSingleByte(defs.MDMCFG2,0x30) #Modem Configuration radio.writeSingleByte(defs.DEVIATN,0x15) #Modem Deviation Setting radio.writeSingleByte(defs.MCSM0,0x18) #Main Radio Control State Machine Configuration radio.writeSingleByte(defs.FOCCFG,0x16) #Frequency Offset Compensation Configuration radio.writeSingleByte(defs.AGCCTRL0,0x92)#AGC Control radio.writeSingleByte(defs.WORCTRL,0xFB) #Wake On Radio Control radio.writeSingleByte(defs.FREND0,0x11) #Front End TX Configuration radio.writeSingleByte(defs.FSCAL3,0xE9) #Frequency Synthesizer Calibration radio.writeSingleByte(defs.FSCAL2,0x2A) #Frequency Synthesizer Calibration radio.writeSingleByte(defs.FSCAL1,0x00) #Frequency Synthesizer Calibration radio.writeSingleByte(defs.FSCAL0,0x1F) #Frequency Synthesizer Calibration radio.writeSingleByte(defs.TEST2,0x81) #Various Test Settings radio.writeSingleByte(defs.TEST1,0x35) #Various Test Settings radio.writeSingleByte(defs.TEST0,0x09) #Various Test Settings
As I Understood from AN, to send in TX transparent mode, I need to toggle pin, connected to GD0 (GD0 is set as INPUT)
So, I write my init and strobed to TX
PA_TABLE = [0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00] spi = SPI(1, baudrate=1125000, polarity=0, phase=0, bits=8, firstbit=SPI.MSB, sck=Pin(22), mosi=Pin(23), miso=Pin(21)) radio = cc1101.CC1101(spi=spi) radio.reset() setDefaultValues() radio.writeBurst(defs.PATABLE, PA_TABLE) radio.sidle() radio.selfTest() print("CC1101 radio initialized\r\n") radio.setTXState() radio.selfTest() OUTPUT: init CC1101 configuration... PARTNUM 0x00 VERSION 0x14 MARCSTATE 0x01 (IDLE) CC1101 radio initialized PARTNUM 0x00 VERSION 0x14 MARCSTATE 0x13 (TX)
Next, I'm trying to send data, changing the state of pin is connected to GD0
def sendRawData(self, code1, code2, Pe): code1 = (code1 << 16) + 257 * urandom.getrandbits(8) print("0x%08X 0x%08X" % (code1, code2)) self.__sendANMotors(code1, code2, Pe) #ToDo: если не установлен callback #self.tx_cb(code1, code2) if self.tx_cb is not None else None utime.sleep_ms(1000) return True def __sendANMotors(self, c1, c2, Pe): for j in range(0, 4): # sending preamble with 12 bit for i in range(0, 12): utime.sleep_us(Pe) self.gd0.on() utime.sleep_us(Pe) self.gd0.off() utime.sleep_us(Pe * 10) #send code1 for i in range(4 * 8, 0, -1): self.__sendBit(c1 >> (i - 1) & 1, Pe) #send code2 for i in range(4 * 8, 0, -1): self.__sendBit(c2 >> (i - 1) & 1, Pe) #send a few bits self.__sendBit(1, Pe) self.__sendBit(1, Pe) utime.sleep_us(Pe * 39) def __sendBit(self, b, Pe): if b == 0: self.gd0.on() # 0 utime.sleep_us(Pe * 2) self.gd0.off() utime.sleep_us(Pe) else: self.gd0.on() # 1 utime.sleep_us(Pe) self.gd0.off() utime.sleep_us(Pe * 2) sendRawData(0x2020, 0x456AAA32, 420)
My RTL-SDR doesnt show any activities from cc1101, where am I not right?