UART ARM3 MSS处理程序输入后两次致电两次

发布于 2025-02-05 08:32:39 字数 2287 浏览 2 评论 0 原文

原始问题:

为什么我的UART ARM3 MSS功能称为两次?

更新:答案: 因为每个传入的字节都会导致中断。 @第一个中断1个字母在里面。在第二个中断之后,其余数据就在内部。

新问题: 当我编写一个字符串时:“测试”并击中plink/putty中的输入:

  • 首次称为't'的ISR在缓冲区中可用。

这是调试图片: debug

  • 然后下次'e',s','s','t t ','\ n'在缓冲区中。 在这里,类似的“ tatus \ n”而不是“状态\ n” tatus

为什么第一个t覆盖?

问题

(我现在看到有时将整个单词写入缓冲区中。 但不是每次。 我将尝试记录所有传入的数据,直到'\ n'被摧毁。 )

***第一个“ T”去了哪里?** ***为什么要

覆盖

MSS_UART_init(&g_mss_uart0, MSS_UART_115200_BAUD, MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY);

这是我的处理程序描述 它打印出读取的内容。 它也将其传递到以后处理的“命令”和“ value_str”变量。

Interrupt -> uart handler -> nothing
But it behaves like
Interrupt -> uart handler -> Interrupt -> uart handler -> nothing

uart处理程序定义:

void uart3_rx_handler(mss_uart_instance_t *this_uart)
{
    unsigned int rx_size = MSS_UART_get_rx(this_uart, g_rx_buff, sizeof(g_rx_buff));
    (void)rx_size;
    // int size  =(int)(rx_size);
    uart_calls_cnt++;

    uart_handler_flag = 0;
    // clear read in variables


    if (strchr((char *)g_rx_buff, '\n') != NULL) {


        // copy into read in variables
        memset(command, 0, 255);              // prepare command
        memset(value_str, 0, 255);            // prepare command
        strcpy(value_str, (char *)g_rx_buff);    // get user input into command
        strcpy(command, (char *)g_rx_buff);      // get user input into command
        value_str[strcspn(value_str, "\n")] = 0; // delete appended \n : works for LF, CR, CRLF, LFCR, ...
        command[strcspn(command, "\n")]     = 0; // delete appended \n : works for LF, CR, CRLF, LFCR, ...
                memset(&g_rx_buff[0], 0, 128); // clear rx buffer
        uart_handler_flag = 1; // so the while(1) loop @ scanf () will break and programm will proceed

    } else {
        // nothing..
    }

Original Question:

Why is my UART ARM3 mss function called twice ?

UPDATE: answer:
Because every incoming Byte will cause an interrupt. @ First interrupt 1 letter is inside. After the second interrupt already the rest data are inside.

New Problem:
When I write a string: "test" and hitting enter in plink/putty:

  • First time the ISR is called 't' is available in the buffer.

This is the debug picture: debug

  • Then next time 'e','s','t','\n' is in the buffer.
    Here a similar screnshoot of "tatus\n" instead of "status\n" tatus

Why is the first t overwritten?

Question

( I right now saw that sometimes the full word is written into the buffer.
But not everytime.
I will try to record all incoming data until a '\n' is decovered. )

*** Where has the first 't' gone?**
*** Why is it overwritten?**

UART init function:

MSS_UART_init(&g_mss_uart0, MSS_UART_115200_BAUD, MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY);

UART set handler function:

MSS_UART_set_rx_handler(&g_mss_uart0, uart3_rx_handler, MSS_UART_FIFO_SINGLE_BYTE);

And here is my handler description
It prints the read out content..
Also it passes it to "command" and "value_str" variable for later processing..

Interrupt -> uart handler -> nothing
But it behaves like
Interrupt -> uart handler -> Interrupt -> uart handler -> nothing

UART handler definition:

void uart3_rx_handler(mss_uart_instance_t *this_uart)
{
    unsigned int rx_size = MSS_UART_get_rx(this_uart, g_rx_buff, sizeof(g_rx_buff));
    (void)rx_size;
    // int size  =(int)(rx_size);
    uart_calls_cnt++;

    uart_handler_flag = 0;
    // clear read in variables


    if (strchr((char *)g_rx_buff, '\n') != NULL) {


        // copy into read in variables
        memset(command, 0, 255);              // prepare command
        memset(value_str, 0, 255);            // prepare command
        strcpy(value_str, (char *)g_rx_buff);    // get user input into command
        strcpy(command, (char *)g_rx_buff);      // get user input into command
        value_str[strcspn(value_str, "\n")] = 0; // delete appended \n : works for LF, CR, CRLF, LFCR, ...
        command[strcspn(command, "\n")]     = 0; // delete appended \n : works for LF, CR, CRLF, LFCR, ...
                memset(&g_rx_buff[0], 0, 128); // clear rx buffer
        uart_handler_flag = 1; // so the while(1) loop @ scanf () will break and programm will proceed

    } else {
        // nothing..
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文