Tool/software: TI-RTOS
Hello All,
I have made few changes to rfpacketTX example and i am sending uart data over the air but Tx packet is not getting transmitted. I am getting PacketNotReceived = 1 in smart Rf studio.I am attaching the file with this post. Please look into the file and suggest what the errors are? Please do reply.
Thank you
2112.rfPacketTx.c
/* * 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 <stdlib.h> #include <xdc/std.h> #include <xdc/runtime/System.h> #include <ti/sysbios/BIOS.h> #include <ti/sysbios/knl/Task.h> #include <ti/sysbios/knl/Semaphore.h> /* Drivers */ #include <ti/drivers/rf/RF.h> #include <ti/drivers/PIN.h> #include <ti/drivers/UART.h> /* Board Header files */ #include "Board.h" #include <stdint.h> #include "smartrf_settings/smartrf_settings.h" /* Pin driver handle */ static PIN_Handle ledPinHandle; static PIN_State ledPinState; /* * Application LED pin configuration table: * - All LEDs board LEDs are off. */ PIN_Config pinTable[] = { Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, PIN_TERMINATE }; /***** Defines *****/ #define TX_TASK_STACK_SIZE 1024 #define TX_TASK_PRIORITY 2 #define UART_TX_TASK_STACK_SIZE 1024 #define UART_TX_TASK_PRIORITY 1 #define CHAR_LINE_END_1 0x0D // Enter #define CHAR_LINE_END_2 0x03 // Enter on numpad Semaphore_Struct semTxStruct; Semaphore_Handle semTxHandle; /* Packet TX Configuration */ #define PAYLOAD_LENGTH 40 #define PACKET_INTERVAL (uint32_t)(4000000*0.5f) /* Set packet interval to 500ms */ /***** Prototypes *****/ static void txTaskFunction(UArg arg0, UArg arg1); static void uarttxTaskFunction(UArg arg0, UArg arg1); /***** Variable declarations *****/ static Task_Params txTaskParams; Task_Struct txTask; /* not static so you can see in ROV */ static uint8_t txTaskStack[TX_TASK_STACK_SIZE]; /***** Variable declarations *****/ static Task_Params uarttxTaskParams; Task_Struct uarttxTask; /* not static so you can see in ROV */ static uint8_t uarttxTaskStack[UART_TX_TASK_STACK_SIZE]; static RF_Object rfObject; static RF_Handle rfHandle; uint32_t time; static uint8_t packet; //char packet; //static uint8_t packet1[] = {}; //static uint16_t seqNumber; static PIN_Handle pinHandle; /***** Function definitions *****/ void TxTask_init(PIN_Handle inPinHandle) { pinHandle = inPinHandle; Task_Params_init(&txTaskParams); txTaskParams.stackSize = TX_TASK_STACK_SIZE; txTaskParams.priority = TX_TASK_PRIORITY; txTaskParams.stack = &txTaskStack; txTaskParams.arg0 = (UInt)1000000; Task_construct(&txTask, txTaskFunction, &txTaskParams, NULL); } void uartTxTask_init(PIN_Handle inPinHandle) { pinHandle = inPinHandle; Task_Params_init(&uarttxTaskParams); uarttxTaskParams.stackSize = UART_TX_TASK_STACK_SIZE; uarttxTaskParams.priority = UART_TX_TASK_PRIORITY; uarttxTaskParams.stack = &uarttxTaskStack; uarttxTaskParams.arg0 = (UInt)1000000; Task_construct(&uarttxTask, uarttxTaskFunction, &uarttxTaskParams, NULL); } static void uarttxTaskFunction(UArg arg0, UArg arg1) { char input; // uint8_t charIndex = 0; //int i = 0; UART_Handle uart; UART_Params uartParams; const char echoPrompt[] = "\fEchoing characters:\r\n"; /* Create a UART with data processing off. */ UART_Params_init(&uartParams); uartParams.writeDataMode = UART_DATA_BINARY; uartParams.readDataMode = UART_DATA_BINARY; uartParams.readReturnMode = UART_RETURN_FULL; uartParams.readEcho = UART_ECHO_ON; uartParams.baudRate = 9600; uart = UART_open(Board_UART0, &uartParams); if (uart == NULL) { System_abort("Error opening the UART"); } UART_write(uart, echoPrompt, sizeof(echoPrompt)); /* Loop forever echoing */ while (1) { UART_read(uart, &input, 1); UART_write(uart, &input, 1); if ((input == (char)CHAR_LINE_END_1) | (input == (char)CHAR_LINE_END_2)) // (charIndex < UART_SERIAL_LINE_SIZE)) { Semaphore_post(semTxHandle); /* reset index to zero to point to begining of the line */ // i = 0; } else { /* Store the input character */ //uartTxBuffer[charIndex++] = input; packet = input; // i++; } } } static void txTaskFunction(UArg arg0, UArg arg1) { Semaphore_pend(semTxHandle, BIOS_WAIT_FOREVER); uint32_t time; RF_Params rfParams; RF_Params_init(&rfParams); RF_cmdPropTx.pktLen = sizeof(packet); RF_cmdPropTx.pPkt = packet; RF_cmdPropTx.startTrigger.triggerType = TRIG_ABSTIME; RF_cmdPropTx.startTrigger.pastTrig = 1; RF_cmdPropTx.startTime = 0; /* Request access to the radio */ rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams); /* Set the frequency */ RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0); /* Get current time */ time = RF_getCurrentTime(); // while(1) // { /* Create packet with incrementing sequence number and random payload */ /* packet[0] = (uint8_t)(seqNumber >> 8); packet[1] = (uint8_t)(seqNumber++); uint8_t i; for (i = 2; i < PAYLOAD_LENGTH; i++) { packet[i] = rand(); }*/ /* Set absolute TX time to utilize automatic power management */ time += PACKET_INTERVAL; RF_cmdPropTx.startTime = time; /* Send packet */ RF_EventMask result = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, NULL, 0); if (!(result & RF_EventLastCmdDone)) { /* Error */ while(1); } PIN_setOutputValue(pinHandle, Board_LED1,!PIN_getOutputValue(Board_LED1)); /* RF_cmdPropTx.pPkt = packet1; RF_cmdPropTx.pktLen = sizeof(packet1); RF_EventMask result1 = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, NULL, 0); if (!(result1 & RF_EventLastCmdDone)) { /* Error */ /* while(1); } PIN_setOutputValue(pinHandle, Board_LED1,!PIN_getOutputValue(Board_LED1));*/ //} } /* * ======== main ======== */ int main(void) { Semaphore_Params semParams; /* Call board init functions. */ Board_initGeneral(); Board_initUART(); /* Open LED pins */ ledPinHandle = PIN_open(&ledPinState, pinTable); if(!ledPinHandle) { System_abort("Error initializing board LED pins\n"); } /* Construct a Semaphore object to be used as a resource lock, inital count 0 */ Semaphore_Params_init(&semParams); Semaphore_construct(&semTxStruct, 0, &semParams); /* Obtain instance handle */ semTxHandle = Semaphore_handle(&semTxStruct); /* Initialize task */ TxTask_init(ledPinHandle); uartTxTask_init(ledPinHandle); /* Start BIOS */ BIOS_start(); return (0); }