This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC2640R2L:打印 UART 上的所有 CPU 异常

Guru**** 2382630 points
Other Parts Discussed in Thread: CC2640R2L, CC2640
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1299525/cc2640r2l-print-all-cpu-exceptions-on-uart

器件型号:CC2640R2L
主题中讨论的其他器件: CC2640

您好、TI 支持团队、

我想打印 CC2640R2L 的 UART0上的所有异常。

我 使用以下配置、但不起作用。

app_ble.cfg

var SysMin = xdc.useModule('xdc.runtime.SysMin');
//SysMin.bufSize = 128;
//System.SupportProxy = SysMin;
var SysCallback = xdc.useModule('xdc.runtime.SysCallback');
System.SupportProxy = SysCallback;
//SysCallback.abortFxn = "&myUserAbort";
//SysCallback.exitFxn  = "&myUserExit";
//SysCallback.flushFxn = "&myUserFlush";
//SysCallback.putchFxn = "&myUserPutch";

SysCallback.exitFxn = "&xdc_runtime_SysMin_exit__E";  /* This is the generated symbol for SysMin_exit */
SysCallback.putchFxn = "&glue_putchar";
SysCallback.abortFxn = "&my_UARTAbort";
//SysCallback.readyFxn = "&myUserReady";

m3Hwi.enableException = false;
//m3Hwi.excHandlerFunc = null;
m3Hwi.excHookFunc = "&excHookFunc"

处理程序:

#include <ti/sysbios/family/arm/m3/Hwi.h>
volatile uintptr_t *excPC = 0;
volatile uintptr_t *excCaller = 0;
void excHookFunc(Hwi_ExcContext *ctx)
{
    excPC = ctx->pc;
    excCaller = ctx->lr;

    char* buf = "Hello\n"; //Print anything just to make sure the handler is working
    for (int i=0; i<5; ++i)
    {
        glue_putchar(buf[i]);
    }
    while(2);
}

void glue_putchar(char ch)
{
    UART_write(uart_handle, &ch, 1);
}

void my_UARTAbort(CString str)
{
    int len = strlen(str);
    for (int i=0; i<len;++i)
    {
        glue_putchar(str[i]);
    }
}

发生异常时、我在 UART 上看不到任何内容、调试器开始在控制台中打印以下内容。

Cortex_M3_0: Can't Run Target CPU: (Error -2134 @ 0x0) Unable to control device execution state. Reset the device, and retry the operation. If error persists, confirm configuration, power-cycle the board, and/or try more reliable JTAG settings (e.g. lower TCLK). (Emulation package 9.12.0.00150) 
Cortex_M3_0: Error: (Error -1170 @ 0x0) Unable to access the DAP. Reset the device, and retry the operation. If error persists, confirm configuration, power-cycle the board, and/or try more reliable JTAG settings (e.g. lower TCLK). (Emulation package 9.12.0.00150) 
Cortex_M3_0: Unable to determine target status after 20 attempts
Cortex_M3_0: 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 debugging

我在 excHookFunc 的内部放置了一个断点、我可以命中该断点、但不知道为什么 UART 不能打印。

这是 CCS 的屏幕截图、其中显示 UART_Handle 和 UartParams 的值

CCS v12.4

TI BLEStack (SDK v5_30_00_03)

您能告诉我缺少什么吗?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    CCS 控制台中的打印输出来自 CCS 组件本身、并不源自器件 UART。

    要查看器件 UART 输出、请尝试连接到串行终端、例如 PuTTY。

    谢谢。
    托比

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我已将串行终端(PuTTY)连接到 CC2640 Launchpad "XDS110 Class Application/User UART (COM21)"、但看不到任何内容。

    我知道连接工作正常、因为我使用 TI 提供的 uartlog.c 模块从应用程序中打印一些日志。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    是否可以共享您的函数"gote_putchar"?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    它已经在 OP 中共享、但在这里是:

    void glue_putchar(char ch)
    {
        /* Use TI UART Driver to print a single character */
        UART_write(uart_handle, &ch, 1);
    }

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    谢谢大家的分享、我在 OP 中忽略了这一点。

    由于异常/faultISR 在中断上下文中运行、因此无法在其中进行阻塞调用。
    在屏幕截图中、UART 写模式为 UART_MODE_BLOCKING。 您是否可以将其改为 UART_MODE_CALLBACK (以及注册一个虚拟 writeCallback)?