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.

callback function WoR Mode CC1310

Other Parts Discussed in Thread: CC1310

Me and my friend, we are working on a project here in our apartment through the communication of two CC1310 through the UART. My friend has already opened two posts and thanks to you we found some chinks to finish it. Now I'm debugging all the code, but I found some anomalies. Right now the WoR Mode works quite well, the two devices communicate with each other by exchanging messages. I have these questions:

1) Using RX-TX in a single device, I find myself as a consumer 1uA. It seems that the transmission is always on. How can I solve this?

2) In the Callback function, I store the packetDataPointer variable inside an MAX_LENGTH array, I try to print this variable out to the callback function, but it doesn't work. Within the function, yes. Why?

3) When I want to send the package, I have the packet value [0] in RF_cmdPropTXAdv.pktLen. I'm sending characters from the serial, so if I send "test" I have 4 characters and this must be the length. So, I opted to use RF_cmdPropTXAdv.pktLen = strlen (myvariable), but with this function it doesn't print anything on the reception.

Can anyone give me some information?

Thanks! 

  • Hi TER, unfortunately that post my friend has messed up with debugging and failed to finish some things. I can debug perfectly and I carried out the code. Could you give me some information about the problems I have?

  • What does "debug perfectly" mean? 

    1) Using RX-TX in a single device, I find myself as a consumer 1uA. It seems that the transmission is always on. How can I solve this?

    A: If you are using 1 uA you are in standby or using a low duty cycle. How do you conclude that you are in continuously TX from this?  

    2) In the Callback function, I store the packetDataPointer variable inside an MAX_LENGTH array, I try to print this variable out to the callback function, but it doesn't work. Within the function, yes. Why?

    A: You should not print anything from a callback since this typically could mess up the timing

    3) When I want to send the package, I have the packet value [0] in RF_cmdPropTXAdv.pktLen. I'm sending characters from the serial, so if I send "test" I have 4 characters and this must be the length. So, I opted to use RF_cmdPropTXAdv.pktLen = strlen (myvariable), but with this function it doesn't print anything on the reception.

    A: What do you receive on the RF before you send it on the UART? 

    You have to get the RF part working before you start using UART. You have to get RF without WOR to work before WOR and so on. 

  • What are you inputting on the UART on the TX side that you want to output on the UART on the RX side?

    Siri

  • A: I'm not on StandBy, but I'm on low consumption. Surely, that 1 uA is the transmission part because I also tested it in the example.

    B: In the callback I have this type of:

     UART_write (uart, & From_RF1, packetLength);

    I insert it in the function Read from RF (), but it does not print anything. But in callback (), it works.

    C: I debugged Input before sending it on the RF, if I write "hello", I see hello in the debug and send it on the RF

    Without Wor Mode it works perfectly, but with WoR Mode I see this small problems

  • Hi Siri, I have two device with RX-TX implemented. Then I can exchange the message with UART. If I write "hello" on Board1, I would like to receive "hello" on board 2 and the other way around

  • A: Not sure what the question is. Do you need the average current consumption below 1 uA? 

    Did you try to get the WOR to work without UART?

  • A: Yes. I worked with the WoR examples also with the UART. But I think I understand where the problem is. For other questions, could you give me some indication?

  • Sorry TER,this is a part of code. In this moment I would like to printf in Read_From_RF, but not works. 

    void Read_From_RF(char RFRead[MAX_LENGTH + NUM_APPENDED_BYTES - 4])
    {
        uint8_t i;
    
        if (RFRead != NULL)
        {
            for (i = 4; i < MAX_LENGTH; i++) Data_from_RF[i-4] = RFRead[i];
            Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
            UART_write(uart,&Data_from_RF,packetLength);
        }
    }
    void RS232()
     if (From_RF1[0] != NULL)                                    
            {
                Read_From_RF(From_RF1);                                                               
                for (i = 0; i < MAX_LENGTH; i++) From_RF1[i] = NULL;    
                for (i = 0; i < MAX_LENGTH; i++) Data_from_RF[i] = NULL;  
            }
    
    void call_RF_RX(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
    {
    
        if (e & RF_EventRxEntryDone)
        {
       //     do{
    
                                /* Toggle LED on RX */
                                PIN_setOutputValue(pinHandle, Relay_2, !PIN_getOutputValue(Relay_2));
    
                                /* Get current unhandled data entry */
                                currentDataEntry = RFQueue_getDataEntry();
    
                                /* Handle the packet data, located at &currentDataEntry->data:
                                 * - Length is the first byte with the current configuration
                                 * - Data starts from the second byte */
                                packetLength      = *(uint8_t*)(&currentDataEntry->data);
                                packetDataPointer = (uint8_t*)(&currentDataEntry->data + 0);
    
                                /* This code block is added to avoid a compiler warning.
                                * Normally, an application will reference these variables for
                                * useful data. */
    
                                if (From_RF1[0] == NULL) memcpy(From_RF1, packetDataPointer, (packetLength));
    
                                Semaphore_post(semHandle);
    
                                RFQueue_nextEntry();
    
                               // UART_write(uart, &From_RF1, packetLength);
    
                            }
    }
    

    This means that when a packet arrives I read it on PackeDataPointer, insert it inside From_RF1. Then in the RS232 function, I go to insert From_RF1 in the Read_From_RF function, so Data_ from_RF is equal to From_RF1. Why doesn't it print in that function? If I print it in callback From_RF1 prints

  • I tried to help Mark with this before the weekend and I didn't get any useful debug information. The last information I got was that the code never reached the callback. If you actually are able to reach the semaphore_post, do you reach the semaphore_pend in:

    void Read_From_RF(char RFRead[MAX_LENGTH + NUM_APPENDED_BYTES - 4])
    {
        uint8_t i;
    
        if (RFRead != NULL)
    	{
    		for (i = 4; i < MAX_LENGTH; i++) Dato_da_RF[i-4] = RFRead[i];
    		if (comando != 0) return;
    		Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
    		UART_write(uart, &Dato_da_RF, packetLength);
    	}
    }

  • I try to send a "test" string and I get this.

  • If you look at what you receive, the pktLen is set to the first char of what you send meaning that you have to look into how you set pktLen. 

  • This in the code or in smartrf settings code ?

  • You have to debug and find out where you have set the pktLen to the first char in the string.

    This forum does not cover simple 'c' debugging. What you ask about here is not how to use our drivers but basic 'c' programming. 

  • I reviewed the code and compared it with the no WoR code. The RF configuration is the same. Is there anything else I should see?

  • Dear TER, I looked at all the code, nothing strange to me. I compared it with my non-WoR mode code and the length of the package and what I send is the same. On the other hand it works and WoR mode does not. Can you explain me the difference between the two in detail? Please, because I don't know if my project is actually compatible with WoR mode.

  • Sorry TER, In my project I should to communicate with two device. This two device have a remote and local address "7E 7E 7E 7E". Now If I have this in my code WoR:

    void Read_From_RF(char RFRead[MAX_LENGTH + NUM_APPENDED_BYTES - 4])
    {
        uint8_t i;
    
        if (RFRead != NULL)
        {
            for (i = 0; i < 4; i++) Addr_da_RF[i] = RFRead[i];
    
            for (i = 0; i < 4; i++)
            {
                if (Addr_da_RF[i] != MyAddr[i])
                {
                    PIN_setOutputValue(pinHandle, S_ON,Out_Low);
                    for (i = 0; i < MAX_LENGTH; i++) From_RS232[i] = NULL;
                    PIN_setOutputValue(pinHandle, S_ON,Out_High);
                    return;
                }
            }
            for (i = 4; i < MAX_LENGTH; i++) Dato_da_RF[i-4] = RFRead[i];
            Istruzioni(Dato_da_RF);
            if (comando != 0) return;
            Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
            UART_write(uart,&Dato_da_RF,packetLength);
        }
    }
    void TX_To_RF(char input[MAX_LENGTH]){
    
                                  uint8_t i = 0;
    
                                  rfcmdHandle = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
                                  if (PIN_getInputValue(Sel_Mod_Unmod) && input[0] != 0)
                                      {
    
                                  for(i = 0;i<4; i++) packet[i] = RemoteAddr[i];
    
                                             for(i=0; i<strlen(input); i++) packet[i+4] = input[i];
    
                                               RF_cmdPropTxAdv.pPkt = packet;
                                               RF_cmdPropTxAdv.pktLen = strlen(input)+4;
    
                                               RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTxAdv, RF_PriorityNormal, NULL, 0);
    
    
                                      }
    
                                               RF_cancelCmd(rfHandle, rfcmdHandle, 0);
    
    
    }
    
    static void rxTaskFunction(UArg arg0, UArg arg1)
    {
        RF_Params rfParams;
        RF_Params_init(&rfParams);
    
        PINCC26XX_setMux(pinHandle, Relay_1, PINCC26XX_MUX_RFC_GPO0);
    
        initializeTxAdvCmdFromTxCmd(&RF_cmdPropTxAdv, &RF_cmdPropTx);
        initializeSniffCmdFromRxCmd(&RF_cmdPropRxSniff, &RF_cmdPropRx);
    
        if( RFQueue_defineQueue(&dataQueue,
                                rxDataEntryBuffer,
                                sizeof(rxDataEntryBuffer),
                                NUM_DATA_ENTRIES,
                                MAX_LENGTH + NUM_APPENDED_BYTES))
        {
            /* Failed to allocate space for all data entries */
            while(1);
        }
    
        uint32_t datarate = calculateSymbolRate(RF_cmdPropRadioDivSetup.symbolRate.preScale,
                                                    RF_cmdPropRadioDivSetup.symbolRate.rateWord);
    
        configureSniffCmd(&RF_cmdPropRxSniff, WOR_MODE, datarate, WOR_WAKEUPS_PER_SECOND);
    
        /* Modify CMD_PROP_TX command for application needs */
        RF_cmdPropTxAdv.pktLen = MAX_LENGTH;
        RF_cmdPropTxAdv.pPkt = 0;
        RF_cmdPropTxAdv.preTrigger.triggerType = TRIG_REL_START;
        RF_cmdPropTxAdv.preTime = WOR_PREAMBLE_TIME_RAT_TICKS(WOR_WAKEUPS_PER_SECOND);
    
    
        /* Modify CMD_PROP_RX command for application needs */
        RF_cmdPropRxSniff.pQueue = &dataQueue;           /* Set the Data Entity queue for received data */
        RF_cmdPropRxSniff.rxConf.bAutoFlushIgnored = 1;  /* Discard ignored packets from Rx queue */
        RF_cmdPropRxSniff.rxConf.bAutoFlushCrcErr = 1;   /* Discard packets with CRC error from Rx queue */
        RF_cmdPropRxSniff.maxPktLen = MAX_LENGTH;        /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
        RF_cmdPropRxSniff.pOutput = (uint8_t*)&rxStatistics;
    
        /* Request access to the radio */
        rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    
        if (!PIN_getInputValue(Sel_Mod_Unmod)) return;                      // Per unmodulated
        while(1)
        {
    
            /* Set the frequency */
            RF_runCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);     // Per unmodulated
    
            RF_cmdPropRxSniff.startTime += WOR_WAKE_UP_INTERVAL_RAT_TICKS(WOR_WAKEUPS_PER_SECOND);
    
            /* Schedule command, do not wait for completion */
            RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRxSniff, RF_PriorityNormal, &call_RF_RX, RF_EventRxEntryDone);
    
        }
    }
    
    void call_RF_RX(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
    {
    
        if (e & RF_EventRxEntryDone)
        {
       //     do{
    
                                /* Toggle LED on RX */
                                PIN_setOutputValue(pinHandle, Relay_2, !PIN_getOutputValue(Relay_2));
    
                                /* Get current unhandled data entry */
                                currentDataEntry = RFQueue_getDataEntry();
    
                                /* Handle the packet data, located at &currentDataEntry->data:
                                 * - Length is the first byte with the current configuration
                                 * - Data starts from the second byte */
                                packetLength      = *(uint8_t*)(&currentDataEntry->data);
                                packetDataPointer = (uint8_t*)(&currentDataEntry->data + 0);
    
                                /* This code block is added to avoid a compiler warning.
                                * Normally, an application will reference these variables for
                                * useful data. */
    
                                if (From_RF1[0] == NULL) memcpy(From_RF1, packetDataPointer, (packetLength));
    
                                Semaphore_post(semHandle);
    
                                RFQueue_nextEntry();
    
                            }
    }

    Don't communicate. If I have this code with No WoR mode it works. I make a debug, the TX send the message but the RX not receive. Can it be a question of package length? 

    I have: LA-LA-LA-LA-RA-RA-RA-RA MAX_LENGTH 

    LA: Local Address

    RA: Remote Address

    Please, help me because I don't know how to resolve this.

  • TER, do you have a news for me?

  • Hi TER, can you help me, please?

  • You claim that your code works when you don't use WOR. I would assume that you use different RF commands in that case and your issues now is related to not using the RF commands correctly. A few day ago I linked to  which have a case on how to do address filtering. From a brief look I can't see that you have set up your RX side according to this? 

  • I am using CMD_PROP_RX_SNIFF it's the same thing as CMD_PROP_RX_ADV?

  • Sorry, I should have referred to table 25-172 and 25-173 in . Have you set the address fields and have you set bChkAddress? 

  • I have this in my smartrf-setting:

    .pktConf.bChkAddress = 0x0,

    How to set the address fields?

  • .pktConf.bChkAddress = 0x0, means address check off. Meaning that the RX side should not be filtering out packets? 
  • I couldn't understand your description.

  • Do you agree that you haven't activated address filtering based on what you have set bChkAddress to? 

  • yes, then i enable this coomand?

  • If you want address filtering you have to set bChkAddress equal to 1 as pr table 25-172 and 25-173 in the TRM.

  • Ok, I try this. Thanks. Sorry TER, one question. If I have RF_packetRX and TX. Can I to use a pin for to make the device in standby mode? To have a very low consumption?

  • This is covered in the post Mark has open. 

  • Mark is using WoR mode. But if I used my project that is already working, can I use a PIN to activate standby mode?

  • What is the difference between your projects? The code you have posted here looks fairly similar to Mark's code.

    I assume that you can use a pin to go down in standby but you don't gain anything doing so. TI-RTOS will always try to get the chip into the lowest power consumption possible. It's only possible to get to standby if you are not using any resources that require that a given domain is on. As an example you can't go to standby if you have the RF driver and UART driver active. Hence if you want to go to the lowest power state you have to close all drivers. 

    If you would like to use a pin you would need to close onn drives to get the device in standby and hence be required to do exactly the same as when letting TI-RTOS do the job. 

  • To close the RF part, I'm using rf_yield (). My system consumes 6mA. Now I would like to close the RF core after sending the package. But I have problems, it always remains at 6mA. Some advice?