Other Parts Discussed in Thread: SYSBIOS
Tool/software: TI-RTOS
Hi all,
I am using a CC2650LaunchPad and I want to test the UART. I am transmitting well, but I do not receive data. I am united Tx (DIO3) and RX (DIO2). My code transmits but I never receive the data.
This is my code, the UART is configured in main, a thread (TxFxn) transmits data periodically and there is a callback function (uartTxCallback) associated with the transmission and a callback function (uartRxCallback) associated with the reception.
In summary: Transmission is ok but I never recive data.
Can someone please tell me what I have wrong with my code?
Thanks very much.
#include <stdint.h>
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/System.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Clock.h>
/* TI-RTOS Header files */
#include <ti/drivers/UART.h>
#include <ti/drivers/uart/UARTCC26XX.h>
UInt32 sleepTickCount;
/* Example/Board Header files */
#include "Board.h"
#define TASKSTACKSIZE (768)
Task_Struct task0Struct;
Char task0Stack[TASKSTACKSIZE];
char uartTxBuffer[2] = {'A','\n'};
char uartRxBuffer[2] = {0,0};
/* Driver handle shared between the task and the callback function */
UART_Handle uart;
UART_Params uartParams;
/*
* Callback function to use the UART in callback mode. It does nothing.
*/
void uartTxCallback(UART_Handle handle, void *buf, size_t count) {
UART_read(uart, uartRxBuffer, 2);
int a = 0;
return;
}
/* Callback function to use the UART in callback mode. It does nothing.
*/
void uartRxCallback(UART_Handle handle, void *buf, size_t count) {
int a = 0;
return;
}
/*
* ======== conversionStartFxn ========
* Task for this function is created statically. See the project's .cfg file.
*/
void TxFxn(UArg arg0, UArg arg1) {
for(;;)
{
UART_write(uart, uartTxBuffer, 2);
Task_sleep(sleepTickCount);
}
}
/*
* ======== main ========
*/
int main(void) {
Task_Params taskParams;
/* Call board init functions */
Board_initGeneral();
Board_initUART();
UART_Params_init(&uartParams);
uartParams.baudRate = 115200;
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.writeMode = UART_MODE_CALLBACK;
uartParams.writeCallback = uartTxCallback;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readMode = UART_MODE_CALLBACK;
uartParams.readCallback = uartRxCallback;
uartParams.readReturnMode = UART_RETURN_FULL;
uart = UART_open(Board_UART0, &uartParams);
sleepTickCount = 100000 / Clock_tickPeriod;
/* Construct BIOS objects */
Task_Params_init(&taskParams);
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr) TxFxn,
&taskParams, NULL);
System_printf("Starting the ADC Continuous Sampling example\n"
"System provider is set to SysMin. Halt the target to view any SysMin "
"contents in ROV.\n");
/* SysMin will only print to the console when you call flush or exit */
System_flush();
/* Start BIOS */
BIOS_start();
return (0);
}