Tool/software: Code Composer Studio
Hello,
I have a program built where I am trying to develop something that reads UART data and sends UART data within TI-RTOS.
I have run the uartecho.c demo and it works fine however when I try to bring this code into my current TI-Rots program, every character I send returns FF or FE. some characters return FF FF FE. I cannot figure out the cause of this behavior.
Below is my code for the main thread, the uarty initialization and my idle function where the echo lies. (I was trying to do this in a task and i could not get it to work before).
//***** Header Files ********************************************************** // XDC module Header Files #include <xdc/std.h> // XDC "base types" - must be included FIRST #include <xdc/runtime/Types.h> // XDC constants/types used in xdc.runtime pkg #include <xdc/cfg/global.h> // For all BIOS instances created statically in RTOS .cfg file #include <xdc/runtime/Error.h> // For error handling (e.g. Error block) #include <xdc/runtime/System.h> // XDC System functions (e.g. System_abort(), System_printf()) #include <xdc/runtime/Log.h> // TI-RTOS Kernel Header Files #include <ti/sysbios/BIOS.h> // BIOS module API #include <ti/sysbios/knl/Task.h> // Task APIs #include <ti/sysbios/knl/Semaphore.h> // Semaphore APIs #include <ti/sysbios/knl/Clock.h> // Clock APIs #include <ti/drivers/ADC.h> #include <ti/drivers/UART.h> // Standard C Header Files #include <stdint.h> // Standard integer types #include <stddef.h> // Standard variable types and macros // Peripheral Driver Header Files #include "ti_drivers_config.h" // Syscfg Board/Drivers Header file #include <ti/drivers/GPIO.h> // TI GPIO Driver header file #include "myGpio.h" // Header file for myGpio.c #include "myTimers.h" #include "myADC.h" #include "myUART.h" /* * ======== main ======== */ //***** Prototypes ************************************************************ //***** Global Variables ****************************************************** Task_Handle sensorRead, motorActuationDecision, buttonPressed, uartRx; Task_Params taskParams; Error_Block Eb; UART_Handle uart; UART_Params uartParams; //***** Main Loop ************************************************************* int main(void) { Board_init(); myGpio_init(); myTimers_init(); myADC_init(); myUart_init(); Task_Params_init(&taskParams); taskParams.priority=2; taskParams.stackSize=512; // uartRx = Task_create(uartRxFxn, &taskParams, Error_IGNORE); // S_UartRX = Semaphore_create(0, NULL, Error_IGNORE); BIOS_start(); }
Above is my main code. Note that myUart_init is below.
// XDC module Header Files #include <xdc/std.h> // XDC "base types" - must be included FIRST #include <xdc/runtime/Types.h> // XDC constants/types used in xdc.runtime pkg #include <xdc/cfg/global.h> // For all BIOS instances created statically in RTOS .cfg file #include <xdc/runtime/Error.h> // For error handling (e.g. Error block) #include <xdc/runtime/System.h> // XDC System functions (e.g. System_abort(), System_printf()) #include <xdc/runtime/Log.h> #include <stdint.h> #include <stddef.h> /* Driver Header files */ #include <ti/drivers/GPIO.h> #include <ti/drivers/UART.h> /* Driver configuration */ #include "ti_drivers_config.h" // ***Variables********************************************************************// extern UART_Handle uart; extern UART_Params uartParams; extern const char echoPrompt[]; unsigned char rxBuffer; void myUart_init(){ UART_init(); UART_Params_init(&uartParams); 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(CONFIG_UART_0, &uartParams); //UART_write(uart, echoPrompt, sizeof(echoPrompt)); //NOTE IF I UNCOMMENT THIS THE ENTIRE PROGRAM BREAKS. }
Finally, my idle function code is below where the uart read and write lie.
// XDC module Header Files #include <xdc/std.h> // XDC "base types" - must be included FIRST #include <xdc/runtime/Types.h> // XDC constants/types used in xdc.runtime pkg #include <xdc/cfg/global.h> // For all BIOS instances created statically in RTOS .cfg file #include <xdc/runtime/Error.h> // For error handling (e.g. Error block) #include <xdc/runtime/System.h> // XDC System functions (e.g. System_abort(), System_printf()) #include <xdc/runtime/Log.h> // TI-RTOS Kernel Header Files #include <ti/sysbios/BIOS.h> // BIOS module API #include <ti/drivers/UART.h> // Standard C Header Files #include <stdint.h> // Standard integer types #include <stddef.h> // Standard variable types and macros // Peripheral Driver Header Files #include <ti/drivers/Board.h> #include "ti_drivers_config.h" // Syscfg Board/Drivers Header file #include <ti/drivers/GPIO.h> // TI GPIO Driver header file #include "myGpio.h" #include <unistd.h> char rxUART; extern UART_Handle uart; extern UART_Params uartParams; const char echoPrompt[] = "Echoing characters:\r\n"; void myIdleFxn (void) { UART_write(uart, echoPrompt, sizeof(echoPrompt)); //This does nothing! There is no data showing up on the uart. while (1) { UART_read(uart, &rxUART, 1); //Loginfo of the rxUART here shows 127. UART_write(uart, &rxUART, 1); } }
Please any help would be greatly appreciated.