微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI无线射频设计 > cc1310数据收发问题

cc1310数据收发问题

时间:12-23 整理:3721RD 点击:

在做CC1310数据收发测试,当然,两块cc1310通信是没问题的,但想要兼容我们其他的发射模块,于是用的一个CC1310和我们的另一个射频模块做通信测试:

1. CC1310发,另一款RF收,结果:

     a. 当发送的数据内容为01 02 03 04...这样不相同的数据时候,能正常的收到“前导码+同步字+数据内容”

     b. 当发送的数据内容为 00 00 00 00 00...这样全为00的数据时候,收到的数据就比较乱,与“前导码+同步字+数据内容”的帧格式无法对应;

2. CC1310收,另一款RF来发射,由于这款RF的前导码与cc1310不同,于是我将发送包模拟为CC1310的帧格式,即实际发送的为“另一款RF的特定帧头+ cc1310 的(前导码+同步字) + 数据内容”  理论上CC1310能够接收发送帧然后剥离前导码同步字获得数据内容, 但是实际却是半天收不到,过了一会儿smartRF Studio接收窗口出现"Buffer over flow!"  这是咋回事?

 

3. CC1310的前导码只能是“0101”  “1010”  为啥不能像cc1125一样支持4种前导码模式呢?  以后能不能增加“0110”  “1100"这两种模式的?

1. 加个whitening应该会有所改善。

2. 觉得不会。他preamble解不出就没办法。

3. 目前只能支持5和A。

1. 加whitening我会试下。

2. 觉得不会。。。大哥,弄啥咧。。。 原因?不能是主观觉得吧。。 那个buffer over flow的原因是啥?是因为接收到了数据但Radio CPU找不到正确的Preamble和sync,认定为无效数据,但又没有将缓冲区清空,所以才会出现“Buffer over flow"?  但如果是这样,那我将rxConf中的bAutoFlushIgnored 和bAutoFlushCrcErr均置为1,仍然是这样啊!所以能讲原因么。

论坛上的回答请不要惜字如金好么,很多时候大家需要的是搞清楚整明白,就算提问者只要一个答案,但你解释清楚也能方便后来观帖子的人啊!

大神,想向你请教下关于CC1310的一些问题,方便加扣扣吗?1017598227,我的扣扣。

你好,我刚刚开始学习cc1310,请问怎样将RX接收到的数据打印出来?上面用的是什么软件呢?谢谢

你好,该软件已找到,RX接收到的数据可以通过console打印出来吗?

Rx接收到的数据可以在smartRfF Studio下方的空白框里显示出来啊。

你也可以通过代码将接收到的数据通过串口打印出来啊

你自己做的射频模块和CC1310,频点看过吗?有没有偏差?

用频谱分析仪看过,没偏差

前导码是一般0101是给芯片启动时间,真正开始接收是从同步字开始,同步字必须要匹配,否则不会接收,包括最后的校验,校验不对也会认为是错包。

你的另一个模块前导码是多少?整个包是怎样的结构?

您好,请问在easylinkrx中定义rx的地址怎么定义呢?rxPacket.dstAddr[8] ={0};我这样写编译不通过。。

rxPacket.dstAddr[8]在结构体里定义是一个8字节数组,一般用的时候短地址,就用一位,例程中也是这样的,比如目的地址为0xa4,地址可以这样写:

rxPacket.dstAddr[0] = 0xa4;

哦哦,原来是这样,谢谢

请问楼主  能做到数据的同时收发吗?

我现在只能是一个收 一个发  同时收发就会有问题,要么收数据有问题 要么发数据有问题。

芯片同一时间是不可能既收又发的,因为只有一根天线,分时来操作的,但是给用户的体验是收发同时实现。你同时收发估计是空中包有冲突,建议用Listen Before Talk例程做发送。

收发例程可以参考Wireless Sensor Network。

  • The Wireless Sensor Network (WSN) Node and Concentrator examples illustrate how to create a very basic sensor network consisting of one or many Node device(s) and a Concentrator device. The example shows how to form a one-to-many network where the Nodes send messages to the Concentrator.
  • The Node use the Sensor Controller Engine to periodically read the value of the light sensor.
  • Whenever the sensor value change, the main controller wakes up and sends a packet with the value to the Concentrator.
  • The Concentrator is always waiting for incoming packet.
  • Once a packet is received, the Concentrator sends an acknowledgement packet in return and displays the data on an LCD (if the kit has one)

您好:

请问WSN concentrator中的sendack()也是用的listen bofore talk 例程吗?我用按键控制的事件发送信息显示传送失败,请问这是什么原因呢?

/*
 * Copyright (c) 2015-2016, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/***** Includes *****/
#include <xdc/std.h>
#include <xdc/runtime/System.h>

#include "ConcentratorRadioTask.h"

#include <ti/sysbios/BIOS.h>

#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/knl/Event.h>
#include <driverlib/aon_batmon.h>

/* Drivers */
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/PIN.h>

/* Board Header files */
#include "Board.h"

#include "easylink/EasyLink.h"
#include "RadioProtocol.h"


/***** Defines *****/
#define CONCENTRATORRADIO_TASK_STACK_SIZE 1024
#define CONCENTRATORRADIO_TASK_PRIORITY   3

#define RADIO_EVENT_ALL                  0xFFFFFFFF
#define RADIO_EVENT_VALID_PACKET_RECEIVED      (uint32_t)(1 << 0)
#define RADIO_EVENT_INVALID_PACKET_RECEIVED (uint32_t)(1 << 1)

#define CONCENTRATORRADIO_MAX_RETRIES 2
#define NORERADIO_ACK_TIMEOUT_TIME_MS (160)


#define CONCENTRATOR_ACTIVITY_LED Board_LED0

/***** Type declarations *****/
//add by me--begin
enum NodeRadioOperationStatus {
    NodeRadioStatus_Success,
    NodeRadioStatus_Failed,
    NodeRadioStatus_FailedNotConnected,
};
struct RadioOperation {
    EasyLink_TxPacket easyLinkTxPacket;
    uint8_t retriesDone;
    uint8_t maxNumberOfRetries;
    uint32_t ackTimeoutMs;
    enum NodeRadioOperationStatus result;
};
//add by me --end

/***** Variable declarations *****/
static Task_Params concentratorRadioTaskParams;
Task_Struct concentratorRadioTask; /* not static so you can see in ROV */
static uint8_t concentratorRadioTaskStack[CONCENTRATORRADIO_TASK_STACK_SIZE];
Event_Struct radioOperationEvent;  /* not static so you can see in ROV */
static Event_Handle radioOperationEventHandle;

//add by me--begin
static struct DualModeSensorPacket dmSensorPacket;
static struct RadioOperation currentRadioOperation;
Event_Struct OperationEvent;  /* not static so you can see in ROV */
static Event_Handle OperationEventHandle;
//add by me --end

static ConcentratorRadio_PacketReceivedCallback packetReceivedCallback;
static union ConcentratorPacket latestRxPacket;
static EasyLink_TxPacket txPacket;
static struct AckPacket ackPacket;
static uint8_t concentratorAddress;
static int8_t latestRssi;


/***** Prototypes *****/
static void concentratorRadioTaskFunction(UArg arg0, UArg arg1);
static void rxDoneCallback(EasyLink_RxPacket * rxPacket, EasyLink_Status status);
static void notifyPacketReceived(union ConcentratorPacket* latestRxPacket);
static void sendAck(uint8_t latestSourceAddress);
static void sendDmPacket(struct DualModeSensorPacket sensorPacket, uint8_t maxNumberOfRetries, uint32_t ackTimeoutMs);
void buttonCallback(PIN_Handle handle, PIN_Id pinId);

static void TxcontrolTaskFunction(UArg arg0, UArg arg1);
/* Pin driver handle */
static PIN_Handle ledPinHandle;
static PIN_State ledPinState;

//add by me--begin
/***** Defines *****/
#define TXCONTROL_TASK_STACK_SIZE 1024
#define TXCONTROL_TASK_PRIORITY   2

static Task_Params TxcontrolTaskParams;
Task_Struct TxcontrolTask;    /* not static so you can see in ROV */
static uint8_t TxcontrolTaskStack[TXCONTROL_TASK_STACK_SIZE];

#define NODERADIO_MAX_RETRIES 2
#define NORERADIO_ACK_TIMEOUT_TIME_MS (160)
static PIN_Handle buttonPinHandle;
static PIN_State buttonPinState;
static uint32_t prevTicks;
//static uint8_t txevents= 0;
//add by me--end

/* Configure LED Pin */

PIN_Config ledPinTable[] = {
        CONCENTRATOR_ACTIVITY_LED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,	Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,//add by me	Board_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,//add by me	Board_LED3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,//add by me
    PIN_TERMINATE
};
//add by me --begin
PIN_Config buttonPinTable[] = {
    Board_BUTTON0  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
	Board_BUTTON1  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
	Board_BUTTON2  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
	Board_BUTTON3  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
    Board_BUTTON4  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
   PIN_TERMINATE
};
//add by me--end

/***** Function definitions *****/
void ConcentratorRadioTask_init(void) {

    /* Open LED pins */
    ledPinHandle = PIN_open(&ledPinState, ledPinTable);
    if (!ledPinHandle)
    {
        System_abort("Error initializing board 3.3V domain pins\n");
    }
    buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable);
    	      	        	    	           if (!buttonPinHandle)
    	      	        	    	           {
    	      	        	    	              System_abort("Error initializing button pins\n");
    	      	        	    	           }
    /* Create event used internally for state changes */
    Event_Params eventParam;
    Event_Params_init(&eventParam);
    Event_construct(&radioOperationEvent, &eventParam);
    radioOperationEventHandle = Event_handle(&radioOperationEvent);

    Event_construct(&OperationEvent, &eventParam);
    OperationEventHandle = Event_handle(&OperationEvent);

    /* Create the concentrator radio protocol task */
    Task_Params_init(&concentratorRadioTaskParams);
    concentratorRadioTaskParams.stackSize = CONCENTRATORRADIO_TASK_STACK_SIZE;
    concentratorRadioTaskParams.priority = CONCENTRATORRADIO_TASK_PRIORITY;
    concentratorRadioTaskParams.stack = &concentratorRadioTaskStack;
    Task_construct(&concentratorRadioTask, concentratorRadioTaskFunction, &concentratorRadioTaskParams, NULL);

    /* Create the concentrator radio protocol task */
    	    Task_Params_init(&TxcontrolTaskParams);
    	    TxcontrolTaskParams.stackSize = TXCONTROL_TASK_STACK_SIZE;
    	    TxcontrolTaskParams.priority = TXCONTROL_TASK_PRIORITY;
    	    TxcontrolTaskParams.stack = &TxcontrolTaskStack;
    	    Task_construct(&TxcontrolTask, TxcontrolTaskFunction, &TxcontrolTaskParams, NULL);
}

void ConcentratorRadioTask_registerPacketReceivedCallback(ConcentratorRadio_PacketReceivedCallback callback) {
    packetReceivedCallback = callback;
}

static void concentratorRadioTaskFunction(UArg arg0, UArg arg1)
{
    /* Initialize EasyLink */
    if(EasyLink_init(RADIO_EASYLINK_MODULATION) != EasyLink_Status_Success) {
        System_abort("EasyLink_init failed");
    }

    /* Set frequency */
    if(EasyLink_setFrequency(RADIO_FREQUENCY) != EasyLink_Status_Success) {
        System_abort("EasyLink_setFrequency failed");
    }

    /* Set concentrator address */;
    concentratorAddress = RADIO_CONCENTRATOR_ADDRESS;
    EasyLink_enableRxAddrFilter(&concentratorAddress, 1, 1);

    /* Set up Ack packet */
    ackPacket.header.sourceAddress = concentratorAddress;
    ackPacket.header.packetType = RADIO_PACKET_TYPE_ACK_PACKET;

    /* Enter receive */
    if(EasyLink_receiveAsync(rxDoneCallback, 0) != EasyLink_Status_Success) {
        System_abort("EasyLink_receiveAsync failed");
    }

    while (1) {
        uint32_t events = Event_pend(radioOperationEventHandle, 0, RADIO_EVENT_ALL, BIOS_WAIT_FOREVER);

        /* If valid packet received */
        if(events & RADIO_EVENT_VALID_PACKET_RECEIVED) {

            /* Send ack packet */
            sendAck(latestRxPacket.header.sourceAddress);



            /* Call packet received callback */
            notifyPacketReceived(&latestRxPacket);

            /* Go back to RX */
            if(EasyLink_receiveAsync(rxDoneCallback, 0) != EasyLink_Status_Success) {
                System_abort("EasyLink_receiveAsync failed");
            }

            /* toggle Activity LED */
            PIN_setOutputValue(ledPinHandle, CONCENTRATOR_ACTIVITY_LED,
                    !PIN_getOutputValue(CONCENTRATOR_ACTIVITY_LED));
        }

        /* If invalid packet received */
        if(events & RADIO_EVENT_INVALID_PACKET_RECEIVED) {
            /* Go back to RX */
            if(EasyLink_receiveAsync(rxDoneCallback, 0) != EasyLink_Status_Success) {
                System_abort("EasyLink_receiveAsync failed");
            }
        }
    }
}

static void TxcontrolTaskFunction(UArg arg0, UArg arg1){
	 /* Setup ADC sensor packet */
		 	   // dmSensorPacket.header.sourceAddress = RADIO_CONCENTRATOR_ADDRESS;
		 	   dmSensorPacket.header.sourceAddress =1;
		 	    dmSensorPacket.header.packetType = RADIO_PACKET_TYPE_DM_SENSOR_PACKET;


		 	    /* Initialise previous Tick count used to calculate uptime for the TLM beacon */
		 	    prevTicks = Clock_getTicks();

		         dmSensorPacket.batt = AONBatMonBatteryVoltageGet();

		         dmSensorPacket.button = !PIN_getInputValue(Board_BUTTON0);

		 	    dmSensorPacket.time100MiliSec=prevTicks;
		 	   /* Setup callback for button pins */
		 	 	 if (PIN_registerIntCb(buttonPinHandle, &buttonCallback) != 0)
		 	 	   {
		 	 	  System_abort("Error registering button callback function");
		 	 	   }

	while(1)
	{
		uint32_t txevents = Event_pend(OperationEventHandle, 0, RADIO_EVENT_ALL, BIOS_WAIT_FOREVER);
		        if(txevents & RADIO_EVENT_VALID_PACKET_RECEIVED)
		        {
		        	sendDmPacket(dmSensorPacket, NODERADIO_MAX_RETRIES, NORERADIO_ACK_TIMEOUT_TIME_MS);
		        	        	 /* toggle Activity LED */
		        PIN_setOutputValue(ledPinHandle, CONCENTRATOR_ACTIVITY_LED,
		        	        	                     !PIN_getOutputValue(CONCENTRATOR_ACTIVITY_LED));
		        //txevents=0;
		        }

	}
}


static void sendAck(uint8_t latestSourceAddress) {

    /* Set destinationAdress, but use EasyLink layers destination adress capability */
    txPacket.dstAddr[0] = latestSourceAddress;

    /* Copy ACK packet to payload, skipping the destination adress byte.
     * Note that the EasyLink API will implcitily both add the length byte and the destination address byte. */
    memcpy(txPacket.payload, &ackPacket.header, sizeof(ackPacket));
    txPacket.len = sizeof(ackPacket);

    /* Send packet  */
    if (EasyLink_transmit(&txPacket) != EasyLink_Status_Success)
    {
        System_abort("EasyLink_transmit failed");
    }
}

static void notifyPacketReceived(union ConcentratorPacket* latestRxPacket)
{
    if (packetReceivedCallback)
    {
        packetReceivedCallback(latestRxPacket, latestRssi);
    }
}

static void rxDoneCallback(EasyLink_RxPacket * rxPacket, EasyLink_Status status)
{
    union ConcentratorPacket* tmpRxPacket;

    /* If we received a packet successfully */
    if (status == EasyLink_Status_Success)
    {
        /* Save the latest RSSI, which is later sent to the receive callback */
        latestRssi = (int8_t)rxPacket->rssi;

        /* Check that this is a valid packet */
        tmpRxPacket = (union ConcentratorPacket*)(rxPacket->payload);

        /* If this is a known packet */
        if (tmpRxPacket->header.packetType == RADIO_PACKET_TYPE_ADC_SENSOR_PACKET)
        {
            /* Save packet */
            memcpy((void*)&latestRxPacket, &rxPacket->payload, sizeof(struct AdcSensorPacket));

            /* Signal packet received */
            Event_post(radioOperationEventHandle, RADIO_EVENT_VALID_PACKET_RECEIVED);
        }
        else if (tmpRxPacket->header.packetType == RADIO_PACKET_TYPE_DM_SENSOR_PACKET)
        {
            /* Save packet */
            memcpy((void*)&latestRxPacket, &rxPacket->payload, sizeof(struct DualModeSensorPacket));

            /* Signal packet received */
            Event_post(radioOperationEventHandle, RADIO_EVENT_VALID_PACKET_RECEIVED);
        }
        else
        {
            /* Signal invalid packet received */
            Event_post(radioOperationEventHandle, RADIO_EVENT_INVALID_PACKET_RECEIVED);
        }
    }
    else
    {
        /* Signal invalid packet received */
        Event_post(radioOperationEventHandle, RADIO_EVENT_INVALID_PACKET_RECEIVED);
    }
}

void buttonCallback(PIN_Handle handle, PIN_Id pinId)
{
    /* Debounce logic, only toggle if the button is still pushed (low) */
   // CPUdelay(8000*50);
	if (PIN_getInputValue(Board_BUTTON0) == 0)    {
		  CPUdelay(8000*50);
		          Event_post(OperationEventHandle, RADIO_EVENT_VALID_PACKET_RECEIVED);
		         // txevents=1;        PIN_setOutputValue(ledPinHandle, Board_LED1,!PIN_getOutputValue(Board_LED1));
    }    if (PIN_getInputValue(Board_BUTTON1) == 0)      {
          PIN_setOutputValue(ledPinHandle, Board_LED2,!PIN_getOutputValue(Board_LED2));
      }    if (PIN_getInputValue(Board_BUTTON2) == 0)          {
    	PIN_setOutputValue(ledPinHandle, Board_LED3,!PIN_getOutputValue(Board_LED3));
          }    if (PIN_getInputValue(Board_BUTTON3) == 0)              {
        	PIN_setOutputValue(ledPinHandle, Board_LED3,!PIN_getOutputValue(Board_LED3));
              }   if (PIN_getInputValue(Board_BUTTON4) == 0)              {    	PIN_setOutputValue(ledPinHandle, Board_LED3,!PIN_getOutputValue(Board_LED3));
              }

}

static void sendDmPacket(struct DualModeSensorPacket sensorPacket, uint8_t maxNumberOfRetries, uint32_t ackTimeoutMs)
{

    /* Set destination address in EasyLink API */
    currentRadioOperation.easyLinkTxPacket.dstAddr[0] = 0;

    /* Copy ADC packet to payload
     * Note that the EasyLink API will implcitily both add the length byte and the destination address byte. */
    memcpy(currentRadioOperation.easyLinkTxPacket.payload, ((uint8_t*)&dmSensorPacket), sizeof(struct DualModeSensorPacket));
    currentRadioOperation.easyLinkTxPacket.len = sizeof(struct DualModeSensorPacket);

    /* Setup retries */
    currentRadioOperation.maxNumberOfRetries = maxNumberOfRetries;
    currentRadioOperation.ackTimeoutMs = ackTimeoutMs;
    currentRadioOperation.retriesDone = 0;
    EasyLink_setCtrl(EasyLink_Ctrl_AsyncRx_TimeOut, EasyLink_ms_To_RadioTime(ackTimeoutMs));

    /* Send packet  */
    if (EasyLink_transmit(&currentRadioOperation.easyLinkTxPacket) != EasyLink_Status_Success)
    {
        System_abort("EasyLink_transmit failed");
    }

    /* Enter RX */


    if (EasyLink_receiveAsync(rxDoneCallback, 0) != EasyLink_Status_Success)
        {
            System_abort("EasyLink_receiveAsync failed");
        }
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top