Part Number: CC2650
Other Parts Discussed in Thread: SYSBIOS,
Tool/software: TI C/C++ Compiler
Hello,
I'm using ccs2650 launchpad to receive a packet from another device using smartRF studio 7 and save this packet in NV area by using osal_write and read and show it using UART
but the Problem is using osal_snv_init() which will cause a problem and when I delete it I'm able to receive normally but I can't save the packet ,I don't know what is the relation between using osal_snv_init() and receiving the packet The error message is: Failed to remove the debug state from the target before disconnecting. There may still be breakpoint op-codes embedded in program memory. It is recommended that you reset the emulator before you connect and reload your program before you continue debuggi
my code is:
#include <stdio.h>
#include <stdlib.h>
// XDCtools Header files
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <xdc/cfg/global.h>
// BIOS Header files
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/drivers/UART.h>
#include "Board.h"
#include <stdint.h>
#include "hal_types.h"
#include "comdef.h"
#include <hal_flash.h>
#include <osal.h>
#include <osal_snv.h>
#include <driverlib/vims.h>
#include <driverlib/aon_batmon.h>
#include <hal_defs.h>
#include <hal_assert.h>
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/PIN.h>
#include <driverlib/rf_prop_mailbox.h>
#include "RFQueue.h"
#include "smartrf_settings/smartrf_settings.h"
#define TS 1024
Task_Struct task0Struct;
static uint8_t task0Stack[TS];
#define TASK_PRIORITY 2
#define DATA_ENTRY_HEADER_SIZE 8 /* Constant header size of a Generic Data Entry */
#define MAX_LENGTH 30 /* Max length byte the radio will accept */
#define NUM_DATA_ENTRIES 2 /* NOTE: Only two data entries supported at the moment */
#define NUM_APPENDED_BYTES 2 /* The Data Entries data field will contain:
* 1 Header byte (RF_cmdPropRx.rxConf.bIncludeHdr = 0x1)
* Max 30 payload bytes
* 1 status byte (RF_cmdPropRx.rxConf.bAppendStatus = 0x1) */
static void ReciveThePacket(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
static RF_Object rfObject;
static RF_Handle rfHandle;
/* Buffer which contains all Data Entries for receiving data.
* Pragmas are needed to make sure this buffer is 4 byte aligned (requirement from the RF Core) */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_ALIGN (rxDataEntryBuffer, 4);
static uint8_t rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
MAX_LENGTH,
NUM_APPENDED_BYTES)];
#elif defined(__IAR_SYSTEMS_ICC__)
#pragma data_alignment = 4
static uint8_t rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
MAX_LENGTH,
NUM_APPENDED_BYTES)];
#elif defined(__GNUC__)
static uint8_t rxDataEntryBuffer [RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
MAX_LENGTH, NUM_APPENDED_BYTES)] __attribute__ ((aligned (4)));
#else
#error This compiler is not supported.
#endif
/* Receive dataQueue for RF Core to fill in data */
static dataQueue_t dataQueue;
static rfc_dataEntryGeneral_t* currentDataEntry;
static uint8_t packetLength;
static uint8_t* packetDataPointer;
static uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES - 1]; /* The length byte is stored in a separate variable */
uint8 * MemBuffWrite ;
uint8 * MemBuffRead ;
int i;
uint8 status = SUCCESS;
void ReciveThePacket(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{
UART_Handle uart;
UART_Params uartParams;
// Create a UART with data processing off.
UART_Params_init(&uartParams); //Function to initialize the UART_Params struct to its defaults
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 115200;
uart = UART_open(Board_UART0, &uartParams); //Function to initialize a given UART peripheral
uint8 FlashAdrr= 0x80; // the address for NV is form 0x80 to 0x8F
uint8 AuxVar[30];
memset (AuxVar, '\0', sizeof(AuxVar));
MemBuffRead= (uint8*)malloc (30*sizeof(uint8));
MemBuffWrite = (uint8*)malloc (30*sizeof(uint8));
osal_snv_init();
if (e & RF_EventRxEntryDone)
{
for (i=1;i<6;i++)
{
/* Get current unhandled data entry */
currentDataEntry = RFQueue_getDataEntry();
/* Handle the packet data, located at ¤tDataEntry->data:
* - Length is the first byte with the current configuration
* - Data starts from the second byte */
packetLength = *(uint8_t*)(¤tDataEntry->data);
packetDataPointer = (uint8_t*)(¤tDataEntry->data + 1);
/* Copy the payload + the status byte to the packet variable */
memcpy(packet, packetDataPointer, (packetLength + 1));
strcpy (MemBuffWrite,packet);
status = osal_snv_write(FlashAdrr, 10, MemBuffWrite );
status = osal_snv_read( FlashAdrr, 10, MemBuffRead);
strcpy (AuxVar,MemBuffRead);
System_printf("The packet is successfully received and it its number: %d",i);
System_flush();
System_printf(" The Address of the packet in SV is %x",FlashAdrr);
System_flush();
System_printf(" The packet is %s%x",AuxVar,AuxVar);
System_flush();*/
UART_write(uart, AuxVar, sizeof(AuxVar));
FlashAdrr++;
free(MemBuffWrite); //free address MemBuffWrite
free(MemBuffRead); //free address MemBuffRead */
RFQueue_nextEntry();
}
}
}
Void Taskfunction (UArg arg0, UArg arg1)
{
RF_Params rfParams;
RF_Params_init(&rfParams);
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);
}
/* Modify CMD_PROP_RX command for application needs */
RF_cmdPropRx.pQueue = &dataQueue; /* Set the Data Entity queue for received data */
RF_cmdPropRx.rxConf.bAutoFlushIgnored = 1; /* Discard ignored packets from Rx queue */
RF_cmdPropRx.rxConf.bAutoFlushCrcErr = 1; /* Discard packets with CRC error from Rx queue */
RF_cmdPropRx.maxPktLen = MAX_LENGTH; /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
RF_cmdPropRx.pktConf.bRepeatOk = 1;
RF_cmdPropRx.pktConf.bRepeatNok = 1;
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);
/* Enter RX mode and stay forever in RX */
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &ReciveThePacket, IRQ_RX_ENTRY_DONE);
while(1);
}
// ======== main ========
int main(void)
{
// Call board init functions
Board_initGeneral();
// Board_initUART();
// Construct BIOS objects
Task_Params taskParams ;
Task_Params_init(&taskParams);
taskParams.stackSize = TS;
taskParams.stack = &task0Stack;
taskParams.priority = TASK_PRIORITY;
taskParams.arg0 = (UInt)1000000;
Task_construct(&task0Struct, (Task_FuncPtr)Taskfunction, &taskParams, NULL); //call the function
BIOS_start();
return (0);
}
I'm using SDK ble_sdk_2_02_02_25
The same happens when I try rfPacketRx_CC2650_LAUNCHXL_TI example and put osal_snv_init(); in the callback function
Thank you so much for any help
Best Regards
Bassel