TI中文支持网
TI专业的中文技术问题搜集分享网站

CC1310 UART Echo例程出现程序不运行的现象!

工具使用的是IAR,创建工程,导入TI-RTOS Examples中的UART Echo的例程。

问题:

1.在Debug模式下,在任务中设置断点,程序可以进入到echoFxn()任务中,在串口助手中也能打印调试信息

2.在运行模式下,程序则不进入echoFxn()任务中,串口助手没有任何调试信息。请问是什么原因?

以下为例程代码:主程序中点亮了一个灯,echoFxn()任务中去灭这个灯,这样更方便观察

请各位大佬帮忙解答,万分感谢!

/*
* ======== echoFxn ========
* Task for this function is created statically. See the project's .cfg file.
*/
Void echoFxn(UArg arg0, UArg arg1)
{
char input;
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_OFF;
uartParams.baudRate = 9600;
uart = UART_open(Board_UART0, &uartParams);
PIN_setOutputValue(ledPinHandle, Board_LED1, 0);
Task_sleep(333000/10);
if (uart == NULL) {echo
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);
UART_write(uart, &input, 1);
}
}

/*
* ======== main ========
*/
int main(void)
{

Task_Params taskParams;

/* Call board init functions */
Board_initGeneral();
Board_initUART();

/* Construct BIOS objects */
Task_Params_init(&taskParams);
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr)echoFxn, &taskParams, NULL);

/* Open LED pins */
ledPinHandle = PIN_open(&ledPinState, ledPinTable);
if(!ledPinHandle) {
System_abort("Error initializing board LED pins\n");
}

PIN_setOutputValue(ledPinHandle, Board_LED1, 1);

/* This example has logging and many other debug capabilities enabled */
System_printf("This example does not attempt to minimize code or data "
"footprint\n");
System_flush();

System_printf("Starting the UART Echo example\nSystem 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);
}

Alvin Chen:

你好,multi task可以参考

/** Copyright (c) 2015-2019, 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.*//**======== mutex.c ========*//* XDC module Headers */
#include <xdc/std.h>
#include <xdc/runtime/System.h>/* BIOS module Headers */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Semaphore.h>#include <ti/drivers/Board.h>#define TASKSTACKSIZE512Void task1Fxn(UArg arg0, UArg arg1);
Void task2Fxn(UArg arg0, UArg arg1);Int resource = 0;
Int finishCount = 0;
UInt32 sleepTickCount;Task_Struct task1Struct, task2Struct;
Char task1Stack[TASKSTACKSIZE], task2Stack[TASKSTACKSIZE];
Semaphore_Struct semStruct;
Semaphore_Handle semHandle;/**======== main ========*/
int main()
{/* Construct BIOS objects */Task_Params taskParams;Semaphore_Params semParams;/* Call driver init functions */Board_init();/* Construct writer/reader Task threads */Task_Params_init(&taskParams);taskParams.stackSize = TASKSTACKSIZE;taskParams.stack = &task1Stack;taskParams.priority = 1;Task_construct(&task1Struct, (Task_FuncPtr)task1Fxn, &taskParams, NULL);taskParams.stack = &task2Stack;taskParams.priority = 2;Task_construct(&task2Struct, (Task_FuncPtr)task2Fxn, &taskParams, NULL);/* Construct a Semaphore object to be use as a resource lock, inital count 1 */Semaphore_Params_init(&semParams);Semaphore_construct(&semStruct, 1, &semParams);/* Obtain instance handle */semHandle = Semaphore_handle(&semStruct);/* We want to sleep for 10000 microseconds */sleepTickCount = 10000 / Clock_tickPeriod;BIOS_start();/* Does not return */return(0);
}/**======== task1Fxn ========*/
Void task1Fxn(UArg arg0, UArg arg1)
{UInt32 time;for (;;) {System_printf("Running task1 function\n");if (Semaphore_getCount(semHandle) == 0) {System_printf("Sem blocked in task1\n");}/* Get access to resource */Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);/* Do work by waiting for 2 system ticks to pass */time = Clock_getTicks();while (Clock_getTicks() <= (time + 1)) {;}/* Do work on locked resource */resource += 1;/* Unlock resource */Semaphore_post(semHandle);Task_sleep(sleepTickCount);}
}/**======== task2Fxn ========*/
Void task2Fxn(UArg arg0, UArg arg1)
{for (;;) {System_printf("Running task2 function\n");if (Semaphore_getCount(semHandle) == 0) {System_printf("Sem blocked in task2\n");}/* Get access to resource */Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);/* Do work on locked resource */resource += 1;/* Unlock resource */Semaphore_post(semHandle);Task_sleep(sleepTickCount);finishCount++;if (finishCount == 5) {System_printf("Calling BIOS_exit from task2\n");BIOS_exit(0);}}
}

下面的 demo:

赞(0)
未经允许不得转载:TI中文支持网 » CC1310 UART Echo例程出现程序不运行的现象!
分享到: 更多 (0)