This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TI-RTOS

Other Parts Discussed in Thread: CC1310

I am going to make firmware that can both transmit and receive RF signal.

This program transmit packet received from uart to other module and send packet received from another to uart.

I changed rfWsnNode_CC1310_LAUNCHXL_tirtos_ccs example as follows.

I flashed example into two modules.

At first time, one module sends packets to another, and another receive packet successfully.

But, in the contrast, when another module sends uart packets, first module receive packet only once or no receive, and then, program doesn't work.

Module doesn't receive any packets after transmit packet.

How to change exactly from receive state to transmit state and vice versa?

I used EasyLink_abort() function for that. But It seemed to be very bad.

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


    /* If you wich to use a frequency other than the default use
     * the below API
     * EasyLink_setFrequency(868000000);
     */
    /* Enter main task loop */

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

    while (1)
    {
        /* Wait for an event */
        uint32_t events = Event_pend(radioOperationEventHandle, 0, RADIO_EVENT_ALL, BIOS_WAIT_FOREVER);

        EasyLink_abort();
//        if ( EasyLink_abort() != EasyLink_Status_Success ) {
//            UART_write(uart, "EasyLink_abort failed\n", sizeof("EasyLink_abort failed\n"));
//            System_abort("EasyLink_abort failed");
//        }

        if ( events & RADIO_EVENT_SEND_UART_DATA ) {
//            EasyLink_setCtrl(Ctrl, ui32Value);
            sendUartPacket(uartData, uartLength, NODERADIO_MAX_RETRIES, NORERADIO_ACK_TIMEOUT_TIME_MS);
        }

        if ( events & RADIO_EVENT_UART_PACKET_RECEIVED ) {
            if (EasyLink_receiveAsync(rxDoneCallback, 0) != EasyLink_Status_Success)
            {
                System_abort("EasyLink_receiveAsync failed");
            }
        }
    }
}
static void sendUartPacket(uint8_t *data, uint8_t len, uint8_t maxNumberOfRetries, uint32_t ackTimeoutMs)
{
    currentRadioOperation.easyLinkTxPacket.dstAddr[0] = RADIO_CONCENTRATOR_ADDRESS;

    currentRadioOperation.easyLinkTxPacket.payload[0] = nodeAddress;
    currentRadioOperation.easyLinkTxPacket.payload[1] = RADIO_PACKET_TYPE_UART_PACKET;

    memcpy(currentRadioOperation.easyLinkTxPacket.payload+2, data, len);
    currentRadioOperation.easyLinkTxPacket.len = len + 2;

    /* Setup retries */
    currentRadioOperation.maxNumberOfRetries = 0;
    currentRadioOperation.ackTimeoutMs = 0;
    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");
    }

    if (EasyLink_receiveAsync(rxDoneCallback, 0) != EasyLink_Status_Success)
    {
        System_abort("EasyLink_receiveAsync failed");
    }
}
static void rxDoneCallback(EasyLink_RxPacket * rxPacket, EasyLink_Status status)
{
    struct PacketHeader* packetHeader;

    /* If this callback is called because of a packet received */
    if (status == EasyLink_Status_Success)
    {
        /* Check the payload header */
        packetHeader = (struct PacketHeader*)rxPacket->payload;

        UART_write(uart, "Packet received\n", sizeof("Packet received\n"));

        /* Check if this is an ACK packet */
        if ( packetHeader->packetType == RADIO_PACKET_TYPE_UART_PACKET ) {
            UART_write(uart, rxPacket->payload + 2, rxPacket->len - 2);
            Event_post(radioOperationEventHandle, RADIO_EVENT_UART_PACKET_RECEIVED);
        }

    }
}

  • To confirm: You get the example to work without doing any modifications to the code?

    How have you debugged this; have you tried to do the changes to the example step wise and seen which change that causes the code to fail?
  • Thank you for your reply, TER.
    My aim is to achieve both transmission and reception.
    In that direction, I changed sample rfWsnNode code.
    But problem is in state change from transmission to reception and vice versa.
    At first time, A module transmits packets to B module, and B module receives packets successfully.
    After some time, B module transmits packets to A module.
    But A module doesn't receive any packets, and to be frank, both module doesn't work at all.
    I used EasyLink_abort() function for state change.
    What is my fault? Why program goes die when I change state?

    And one more, sample codes works well such as rfEasyLink_RX and TX and so on.

    But these are only reception and transmission, and I want to make both of them in one chip.

  • The rfWsnNode example is made to be used together with the rfWsnConcentrator example which sends an ack back to the node. The nodes check if the received packet is a ack packet, if not discard the packet.

    If you want to nodes to send data to each other I believe that you shouldn't change too much of the existing code but you have to change the packet type/ what type of packet the nodes send/ receive.

    What is your end goal, are you going to use the example as the base in your product?
  • Thanks TER.

    What is your end goal?

    I am going to make product that can transmit and receive data over the air.

    Of course, this is only my custom product, not for sale.

    Are you going to use the example as the base in your product?

    Yes.

    Best regards.