From 337e72d70c5fc94698b12ceabc4a0eb0bb8dcdc8 Mon Sep 17 00:00:00 2001 From: TobiNakamura Date: Tue, 26 Jun 2018 10:13:30 -0700 Subject: [PATCH 1/3] added CHIME testing sequence. New CC1101 configuration has been added for the upper band (UB) radio. Switching between the LB and UB radio is performed explicitly by writing into spiDataConfig.CSNR. The CHIME test sequence sends a 55 byte random value prefixed by the call sign. --- SFUsat/sfu_smartrf_cc1101.h | 79 +++++++++++++++++++++++++++++++++- SFUsat/sfu_task_radio.c | 86 ++++++++++++++++++++++++++++++++++--- 2 files changed, 158 insertions(+), 7 deletions(-) diff --git a/SFUsat/sfu_smartrf_cc1101.h b/SFUsat/sfu_smartrf_cc1101.h index 521eaf4..63dda0b 100644 --- a/SFUsat/sfu_smartrf_cc1101.h +++ b/SFUsat/sfu_smartrf_cc1101.h @@ -105,7 +105,7 @@ typedef struct { #define SMARTRF_SETTING_RCCTRL0_STATUS_ADDR 0x003D -// TX +// Lower Band #define SMARTRF_SETTING_IOCFG2_VAL_TX 0x1C // on for 3.58us, set HW 1. GDO2 is stuck, no matter the setting a single 35us pulse occures per task cycle #define SMARTRF_SETTING_IOCFG1_VAL_TX 0x2E #define SMARTRF_SETTING_IOCFG0_VAL_TX 0x01 // assert when rf fifo is filled above threshold or end of packet is reached, deassert when fifo is emtpy @@ -168,4 +168,81 @@ typedef struct { #define SMARTRF_SETTING_RCCTRL1_STATUS_VAL_TX 0x00 #define SMARTRF_SETTING_RCCTRL0_STATUS_VAL_TX 0x00 +//Upper Band +//# Modulation Format = 2-FSK +//# PA Ramping = false +//# Packet Length = 62 +//# Packet Length Mode = Fixed packet length mode. Length configured in PKTLEN register +//# no CRC +//# Preamble Count = 4 +//# RX Filter BW = 58.035714 +//# Sync Word Qualifier Mode = 30/32 sync word bits detected +//# TX Power = 0 +//# Whitening = false +//# --------------------------------------------------- +//# Packet sniffer stttings for CC1101 Upper band 790Mhz +//# --------------------------------------------------- +#define SMARTRF_SETTING_IOCFG2_VAL_UB 0x1C +#define SMARTRF_SETTING_IOCFG1_VAL_UB 0x2E +#define SMARTRF_SETTING_IOCFG0_VAL_UB 0x06 +#define SMARTRF_SETTING_FIFOTHR_VAL_UB 0x47 +#define SMARTRF_SETTING_SYNC1_VAL_UB 0xD3 +#define SMARTRF_SETTING_SYNC0_VAL_UB 0x91 +#define SMARTRF_SETTING_PKTLEN_VAL_UB 0x3E +#define SMARTRF_SETTING_PKTCTRL1_VAL_UB 0x00 +#define SMARTRF_SETTING_PKTCTRL0_VAL_UB 0x00 +#define SMARTRF_SETTING_ADDR_VAL_UB 0x00 +#define SMARTRF_SETTING_CHANNR_VAL_UB 0x00 +#define SMARTRF_SETTING_FSCTRL1_VAL_UB 0x06 +#define SMARTRF_SETTING_FSCTRL0_VAL_UB 0x00 +#define SMARTRF_SETTING_FREQ2_VAL_UB 0x1E +#define SMARTRF_SETTING_FREQ1_VAL_UB 0x62 +#define SMARTRF_SETTING_FREQ0_VAL_UB 0x76 +#define SMARTRF_SETTING_MDMCFG4_VAL_UB 0xF5 +#define SMARTRF_SETTING_MDMCFG3_VAL_UB 0x83 +#define SMARTRF_SETTING_MDMCFG2_VAL_UB 0x03 +#define SMARTRF_SETTING_MDMCFG1_VAL_UB 0x22 +#define SMARTRF_SETTING_MDMCFG0_VAL_UB 0xF8 +#define SMARTRF_SETTING_DEVIATN_VAL_UB 0x15 +#define SMARTRF_SETTING_MCSM2_VAL_UB 0x07 +#define SMARTRF_SETTING_MCSM1_VAL_UB 0x30 +#define SMARTRF_SETTING_MCSM0_VAL_UB 0x18 +#define SMARTRF_SETTING_FOCCFG_VAL_UB 0x16 +#define SMARTRF_SETTING_BSCFG_VAL_UB 0x6C +#define SMARTRF_SETTING_AGCCTRL2_VAL_UB 0x03 +#define SMARTRF_SETTING_AGCCTRL1_VAL_UB 0x40 +#define SMARTRF_SETTING_AGCCTRL0_VAL_UB 0x91 +#define SMARTRF_SETTING_WOREVT1_VAL_UB 0x87 +#define SMARTRF_SETTING_WOREVT0_VAL_UB 0x6B +#define SMARTRF_SETTING_WORCTRL_VAL_UB 0xFB +#define SMARTRF_SETTING_FREND1_VAL_UB 0x56 +#define SMARTRF_SETTING_FREND0_VAL_UB 0x10 +#define SMARTRF_SETTING_FSCAL3_VAL_UB 0xE9 +#define SMARTRF_SETTING_FSCAL2_VAL_UB 0x2A +#define SMARTRF_SETTING_FSCAL1_VAL_UB 0x00 +#define SMARTRF_SETTING_FSCAL0_VAL_UB 0x1F +#define SMARTRF_SETTING_RCCTRL1_VAL_UB 0x41 +#define SMARTRF_SETTING_RCCTRL0_VAL_UB 0x00 +#define SMARTRF_SETTING_FSTEST_VAL_UB 0x59 +#define SMARTRF_SETTING_PTEST_VAL_UB 0x7F +#define SMARTRF_SETTING_AGCTEST_VAL_UB 0x3F +#define SMARTRF_SETTING_TEST2_VAL_UB 0x81 +#define SMARTRF_SETTING_TEST1_VAL_UB 0x35 +#define SMARTRF_SETTING_TEST0_VAL_UB 0x0B +#define SMARTRF_SETTING_PARTNUM_VAL_UB 0x00 +#define SMARTRF_SETTING_VERSION_VAL_UB 0x04 +#define SMARTRF_SETTING_FREQEST_VAL_UB 0x00 +#define SMARTRF_SETTING_LQI_VAL_UB 0x00 +#define SMARTRF_SETTING_RSSI_VAL_UB 0x00 +#define SMARTRF_SETTING_MARCSTATE_VAL_UB 0x00 +#define SMARTRF_SETTING_WORTIME1_VAL_UB 0x00 +#define SMARTRF_SETTING_WORTIME0_VAL_UB 0x00 +#define SMARTRF_SETTING_PKTSTATUS_VAL_UB 0x00 +#define SMARTRF_SETTING_VCO_VC_DAC_VAL_UB 0x00 +#define SMARTRF_SETTING_TXBYTES_VAL_UB 0x00 +#define SMARTRF_SETTING_RXBYTES_VAL_UB 0x00 +#define SMARTRF_SETTING_RCCTRL1_STATUS_VAL_UB 0x00 +#define SMARTRF_SETTING_RCCTRL0_STATUS_VAL_UB 0x00 + + #endif /* SFUSAT_SFU_SMARTRF_CC1101_H_ */ diff --git a/SFUsat/sfu_task_radio.c b/SFUsat/sfu_task_radio.c index 484c8c3..45c6378 100644 --- a/SFUsat/sfu_task_radio.c +++ b/SFUsat/sfu_task_radio.c @@ -125,6 +125,41 @@ const uint16 SMARTRF_VALS_TX[NUM_CONFIG_REGISTERS] = { [TEST0] = SMARTRF_SETTING_TEST0_VAL_TX }; +const uint16 SMARTRF_VALS_UB[NUM_CONFIG_REGISTERS] = { + [IOCFG0] = SMARTRF_SETTING_IOCFG0_VAL_UB, + [IOCFG1] = SMARTRF_SETTING_IOCFG1_VAL_UB, + [IOCFG2] = SMARTRF_SETTING_IOCFG2_VAL_UB, + [FIFOTHR] = SMARTRF_SETTING_FIFOTHR_VAL_UB, + [SYNC1] = SMARTRF_SETTING_SYNC1_VAL_UB, + [SYNC0] = SMARTRF_SETTING_SYNC0_VAL_UB, + [PKTLEN] = SMARTRF_SETTING_PKTLEN_VAL_UB, + [PKTCTRL1] = SMARTRF_SETTING_PKTCTRL1_VAL_UB, + [PKTCTRL0] = SMARTRF_SETTING_PKTCTRL0_VAL_UB, + [FSCTRL1] = SMARTRF_SETTING_FSCTRL1_VAL_UB, + [FREQ2] = SMARTRF_SETTING_FREQ2_VAL_UB, + [FREQ1] = SMARTRF_SETTING_FREQ1_VAL_UB, + [FREQ0] = SMARTRF_SETTING_FREQ0_VAL_UB, + [MDMCFG4] = SMARTRF_SETTING_MDMCFG4_VAL_UB, + [MDMCFG3] = SMARTRF_SETTING_MDMCFG3_VAL_UB, + [MDMCFG2] = SMARTRF_SETTING_MDMCFG2_VAL_UB, + [MDMCFG1] = SMARTRF_SETTING_MDMCFG1_VAL_UB, + [MDMCFG0] = SMARTRF_SETTING_MDMCFG0_VAL_UB, + [DEVIATN] = SMARTRF_SETTING_DEVIATN_VAL_UB, + [MCSM1] = SMARTRF_SETTING_MCSM1_VAL_UB, + [MCSM0] = SMARTRF_SETTING_MCSM0_VAL_UB, + [FOCCFG] = SMARTRF_SETTING_FOCCFG_VAL_UB, + [AGCCTRL2] = SMARTRF_SETTING_AGCCTRL2_VAL_UB, + [AGCCTRL1] = SMARTRF_SETTING_AGCCTRL1_VAL_UB, + [WORCTRL] = SMARTRF_SETTING_WORCTRL_VAL_UB, + [FSCAL3] = SMARTRF_SETTING_FSCAL3_VAL_UB, + [FSCAL2] = SMARTRF_SETTING_FSCAL2_VAL_UB, + [FSCAL1] = SMARTRF_SETTING_FSCAL1_VAL_UB, + [FSCAL0] = SMARTRF_SETTING_FSCAL0_VAL_UB, + [TEST2] = SMARTRF_SETTING_TEST2_VAL_UB, + [TEST1] = SMARTRF_SETTING_TEST1_VAL_UB, + [TEST0] = SMARTRF_SETTING_TEST0_VAL_UB +}; + /** * Masks. @@ -469,6 +504,19 @@ static void receivePacket(uint8_t *destPayload) { strobe(SFRX); } +static void chimeTestSequence(){ + char buffer[100] = {'\0'}; + spiDataConfig.CSNR = RF_CONFIG_CS_UB; + + uint8 goldsequence[SMARTRF_SETTING_PKTLEN_VAL_UB-7] = {0x67, 0x87, 0x5d, 0xef, 0xcb, 0x74, 0x0e, 0x55, 0xd1, 0x3f, 0x17, 0xb7, 0xcb, 0x67, 0xcd, 0x10, 0x7e, 0xc6, 0x34, 0xfa, 0x40, 0x11, 0x5e, 0xdc, 0x85, 0x7e, 0x42, 0x70, 0xf9, 0x18, 0x88, 0xbe, 0xf9, 0x65, 0x1c, 0xcd, 0x3b, 0xcc, 0x71, 0x70, 0x5a, 0xeb, 0x7f, 0x89, 0x41, 0xa4, 0x3f, 0xc0, 0x19, 0x7e, 0x5c, 0x45, 0xaa, 0xa4, 0x50}; + + snprintf(buffer, sizeof(buffer), "Sending CHIME cal. signal"); + serialSendln(buffer); + sendPacket(goldsequence, SMARTRF_SETTING_PKTLEN_VAL_UB-7); + + spiDataConfig.CSNR = RF_CONFIG_CS_LB; +} + static void rfTestSequence() { strobe(SNOP); char buffer[100] = {'\0'}; @@ -799,15 +847,17 @@ BaseType_t initRadio() { * CC1101 is active-low, on CS0 * SPI_CS_0 -> 0xFE -> 11111110 */ - spiDataConfig.CSNR = RF_CONFIG_CS_LB; - uint8 *stat = readAllStatusRegisters(); - char buffer[30]; + //---------configure lower band CC1101 + spiDataConfig.CSNR = RF_CONFIG_CS_LB; strobe(SRES); strobe(SNOP); - snprintf(buffer, 30, "Radio Status Registers:"); + uint8 *stat = readAllStatusRegisters(); + char buffer[30]; + + snprintf(buffer, 30, "LB Radio Status Registers:"); serialSendln(buffer); snprintf(buffer, 30, "%02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, ", stat[0], stat[1], stat[2], stat[3], stat[4], stat[5], stat[6], stat[7], stat[8], stat[9], @@ -824,9 +874,33 @@ BaseType_t initRadio() { //attach irq strobe(SRX); -//move here ## -//Move ## + + //---------configure Upper band CC1101 + spiDataConfig.CSNR = RF_CONFIG_CS_UB; + + strobe(SRES); + strobe(SNOP); + + stat = readAllStatusRegisters(); + + snprintf(buffer, 30, "UB Radio Status Registers:"); + serialSendln(buffer); + snprintf(buffer, 30, "%02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, ", + stat[0], stat[1], stat[2], stat[3], stat[4], stat[5], stat[6], stat[7], stat[8], stat[9], + stat[10], stat[11], stat[12], stat[13]); + serialSendln(buffer); + + if(configureRadio(SMARTRF_VALS_UB, PA_TABLE_SETTING)){ + snprintf(buffer, 30, "radio registers do not match!"); + serialSendln(buffer); + } + + strobe(SNOP); + strobe(SIDLE); + + spiDataConfig.CSNR = RF_CONFIG_CS_LB; + return pdPASS; } From 017b3f80ef49767b68f51ef9deac7c2c6139dbef Mon Sep 17 00:00:00 2001 From: TobiNakamura Date: Tue, 26 Jun 2018 13:24:49 -0700 Subject: [PATCH 2/3] chimetest now writes directly into fifo instead of using sendPacket function --- SFUsat/sfu_smartrf_cc1101.h | 2 +- SFUsat/sfu_task_radio.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/SFUsat/sfu_smartrf_cc1101.h b/SFUsat/sfu_smartrf_cc1101.h index 63dda0b..4b11af4 100644 --- a/SFUsat/sfu_smartrf_cc1101.h +++ b/SFUsat/sfu_smartrf_cc1101.h @@ -188,7 +188,7 @@ typedef struct { #define SMARTRF_SETTING_FIFOTHR_VAL_UB 0x47 #define SMARTRF_SETTING_SYNC1_VAL_UB 0xD3 #define SMARTRF_SETTING_SYNC0_VAL_UB 0x91 -#define SMARTRF_SETTING_PKTLEN_VAL_UB 0x3E +#define SMARTRF_SETTING_PKTLEN_VAL_UB 0x37 #define SMARTRF_SETTING_PKTCTRL1_VAL_UB 0x00 #define SMARTRF_SETTING_PKTCTRL0_VAL_UB 0x00 #define SMARTRF_SETTING_ADDR_VAL_UB 0x00 diff --git a/SFUsat/sfu_task_radio.c b/SFUsat/sfu_task_radio.c index 45c6378..f6c062f 100644 --- a/SFUsat/sfu_task_radio.c +++ b/SFUsat/sfu_task_radio.c @@ -508,11 +508,19 @@ static void chimeTestSequence(){ char buffer[100] = {'\0'}; spiDataConfig.CSNR = RF_CONFIG_CS_UB; - uint8 goldsequence[SMARTRF_SETTING_PKTLEN_VAL_UB-7] = {0x67, 0x87, 0x5d, 0xef, 0xcb, 0x74, 0x0e, 0x55, 0xd1, 0x3f, 0x17, 0xb7, 0xcb, 0x67, 0xcd, 0x10, 0x7e, 0xc6, 0x34, 0xfa, 0x40, 0x11, 0x5e, 0xdc, 0x85, 0x7e, 0x42, 0x70, 0xf9, 0x18, 0x88, 0xbe, 0xf9, 0x65, 0x1c, 0xcd, 0x3b, 0xcc, 0x71, 0x70, 0x5a, 0xeb, 0x7f, 0x89, 0x41, 0xa4, 0x3f, 0xc0, 0x19, 0x7e, 0x5c, 0x45, 0xaa, 0xa4, 0x50}; + uint8 goldsequence[SMARTRF_SETTING_PKTLEN_VAL_UB] = {0x67, 0x87, 0x5d, 0xef, 0xcb, 0x74, 0x0e, 0x55, 0xd1, 0x3f, 0x17, 0xb7, 0xcb, 0x67, 0xcd, 0x10, 0x7e, 0xc6, 0x34, 0xfa, 0x40, 0x11, 0x5e, 0xdc, 0x85, 0x7e, 0x42, 0x70, 0xf9, 0x18, 0x88, 0xbe, 0xf9, 0x65, 0x1c, 0xcd, 0x3b, 0xcc, 0x71, 0x70, 0x5a, 0xeb, 0x7f, 0x89, 0x41, 0xa4, 0x3f, 0xc0, 0x19, 0x7e, 0x5c, 0x45, 0xaa, 0xa4, 0x50}; snprintf(buffer, sizeof(buffer), "Sending CHIME cal. signal"); serialSendln(buffer); - sendPacket(goldsequence, SMARTRF_SETTING_PKTLEN_VAL_UB-7); + + strobe(SNOP); + if (writeToTxFIFO(goldsequence, SMARTRF_SETTING_PKTLEN_VAL_UB) == 1) { + snprintf(buffer, sizeof(buffer), "%d Bytes Radio TX FIFO written", SMARTRF_SETTING_PKTLEN_VAL_UB); + serialSendln(buffer); + } else { + snprintf(buffer, sizeof(buffer), "Radio did not write"); + serialSendln(buffer); + } spiDataConfig.CSNR = RF_CONFIG_CS_LB; } From 4dbee5b9eeac6d64f629105df13542dcb1dac23a Mon Sep 17 00:00:00 2001 From: TobiNakamura Date: Tue, 26 Jun 2018 13:44:18 -0700 Subject: [PATCH 3/3] flush fifo before transmitting chime --- SFUsat/sfu_task_radio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SFUsat/sfu_task_radio.c b/SFUsat/sfu_task_radio.c index f6c062f..241d19e 100644 --- a/SFUsat/sfu_task_radio.c +++ b/SFUsat/sfu_task_radio.c @@ -514,6 +514,7 @@ static void chimeTestSequence(){ serialSendln(buffer); strobe(SNOP); + if(statusByte & 0x70 == 0x70){strobe(SFTX);} if (writeToTxFIFO(goldsequence, SMARTRF_SETTING_PKTLEN_VAL_UB) == 1) { snprintf(buffer, sizeof(buffer), "%d Bytes Radio TX FIFO written", SMARTRF_SETTING_PKTLEN_VAL_UB); serialSendln(buffer); @@ -522,6 +523,8 @@ static void chimeTestSequence(){ serialSendln(buffer); } + + strobe(STX); spiDataConfig.CSNR = RF_CONFIG_CS_LB; }