Other Parts Discussed in Thread: CC1310
Hi Team,
I am observing a strange behaviour while executing the UART firmware.
/* * CommandRadio.h * This is header file * Created on: Aug 25, 2016 * Author: vikram */ #ifndef COMMANDRADIO_H_ #define COMMANDRADIO_H_ #include<stdio.h> #include<string.h> /* XDCtools Header files */ #include <xdc/std.h> #include <xdc/runtime/System.h> #include <xdc/runtime/Error.h> #include <xdc/cfg/global.h> /* BIOS Header files */ #include <ti/sysbios/BIOS.h> #include <ti/sysbios/knl/Swi.h> #include <ti/sysbios/knl/Task.h> #include <ti/sysbios/knl/Clock.h> #include <ti/sysbios/knl/Mailbox.h> #include <ti/sysbios/knl/Event.h> /* TI-RTOS Header files */ #include <ti/drivers/PIN.h> #include <ti/drivers/UART.h> /* Board Header files */ #include "Board.h" /*Event Defines */ #define Event_Data_Rx Event_Id_00 #define Event_Button Event_Id_01 typedef struct MsgObj { Int id; /* writer task id */ String buf; /* message value */ } MsgObj, *Msg; /* UART params */ UART_Handle uart; typedef void(*UartRead_Callback)(uint8_t *ch); /*Function Prototypes */ void uartSendTask(UArg arg0,UArg arg1); /* This is the Task that handles the write to terminal call */ void processMsg(MsgObj *message); /* This is called by reciept of a mailbox message */ void writeToTerminal(String txtString); /* This is the function called to send a mesage to back channel UART */ void UartRead_registerCallback(UartRead_Callback callback); #endif /* COMMANDRADIO_H_ */ /* * CommandRadioUart.c * This is source file * Created on: Aug 25, 2016 * Author: vikram */ #include "CommandRadio.h" uint8_t *command; static char uart_rxBuffer;//Read one byte at a time /***** Variable declarations *****/ static UartRead_Callback Callback; /* Prototype */ static void uartReceiveFinished(UART_Handle handle, void *uart_rxBuffer, size_t count); /* This task is declared in CommandRadio.cfg * It transmits text over the UART backchannel USB */ void uartSendTask(UArg arg0,UArg arg1){ MsgObj dataRx; UART_Params uartParams; /*initializing the UART parameters*/ UART_Params_init(&uartParams); uartParams.writeDataMode = UART_DATA_TEXT; uartParams.readMode = UART_MODE_CALLBACK; uartParams.readDataMode = UART_DATA_TEXT; uartParams.readReturnMode = UART_RETURN_FULL; uartParams.readEcho = UART_ECHO_OFF; uartParams.readCallback = uartReceiveFinished; uartParams.baudRate = 115200; uart = UART_open(Board_UART0, &uartParams); if (uart == NULL) {System_abort("Error opening the UART");} // Clear the uart_rxbuffer int rxBytes = UART_read(uart, &uart_rxBuffer, 1); /* The task suspends waiting on reciept of mailbox message.*/ while(TRUE){ UART_read(uart, &uart_rxBuffer, 1); Mailbox_pend(rxDataMailbox, &dataRx, BIOS_WAIT_FOREVER); processMsg(&dataRx); } } void UartRead_registerCallback(UartRead_Callback callback) { Callback = callback; } /* This function writes the Text messge to the UART, The UART write can be formated here */ void processMsg(MsgObj *message){ UART_write(uart, message->buf, strlen(message->buf)); } /* this function can be called to write to the UART */ void writeToTerminal(String txtString){ MsgObj writeData; writeData.id = Event_Data_Rx; writeData.buf = txtString; Mailbox_post(rxDataMailbox,&writeData,BIOS_WAIT_FOREVER); } static void uartReceiveFinished(UART_Handle handle, void *uart_rxBuffer, size_t count) { command = (uint8_t*)uart_rxBuffer; Callback(command); }
If you see the firmware above you will recognise that I am trying to read something from the terminal window and send to the other device over the radio.
The problem occurs that every time I do a power on reset to the CC1310 Launchpad board (meaning trying to power up the board by plugging in the USB cable to the PC system) by default, the execution calls the uart callback function i.e. "uartReceiveFinished" even though I have not punched any key on the keyboard to interact with the terminal window.
I don't observe this behaviour if I press the reset button on the Launchpad nor I observe this behaviour if I run the firmware in debug mode.
I would like to know if there is any conditions set in the UART driver that is specific for the power on reset using the USB port that triggers the UART call back function.
As per my knowledge resetting the board using the reset button or by plugging and unplugging the usb cable should show the same behaviour.
Please correct me if I am wrong.
Thank you in advance.
Vikram