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.

[参考译文] AM263X-MCAL SDK:AM263x-AM263X:MCU-PLUS-SDK DMA RX–DMA 中断不连续工作

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1619986/am263x-mcal-sdk-mcu-plus-sdk-am263x-am263x-uart-dma-rx-dma-interrupt-not-working-continiously

器件型号:AM263X-MCAL SDK

尊敬的团队:

这是我之前的主题尚未解决,但你的家伙大多数时间关闭的门票由自己只是为什么?

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1619090/mcu-plus-sdk-am263x-am263x-uart-dma-rx-data-corruption-after-64-bytes-when-re-arming-variable-length-reception

我查看了您给我的解决方案、它无法正常工作、我将在这里粘贴我的完整代码

/*
 * test.c
 *
 *  Created on: Feb 25, 2026
 *      Author: Swati
 */
#include <kernel/dpl/DebugP.h>
#include <string.h>

#include "ti_board_open_close.h"
#include "ti_drivers_config.h"
#include "ti_drivers_open_close.h"

#define HEADER_SIZE (4U)
#define APP_UART_BUFSIZE (256U)
#define APP_UART_RECEIVE_BUFSIZE (256U)

uint8_t rxcomplete = 0U;
uint32_t baseAddr;
UART_Transaction trans;
UART_Transaction transRx;

uint8_t gUartBuffer[APP_UART_BUFSIZE]
    __attribute__((aligned(CacheP_CACHELINE_ALIGNMENT)));
uint8_t gUartReceiveBuffer[APP_UART_RECEIVE_BUFSIZE]
    __attribute__((aligned(CacheP_CACHELINE_ALIGNMENT)));

volatile uint32_t gNumBytesRead = 0U, gNumBytesWritten = 0U;

#define APP_UART_ASSERT_ON_FAILURE(transferOK, transaction)     \
  do {                                                          \
    if ((SystemP_SUCCESS != (transferOK)) ||                    \
        (UART_TRANSFER_STATUS_SUCCESS != transaction.status)) { \
      DebugP_assert(FALSE); /* UART TX/RX failed!! */           \
    }                                                           \
  } while (0)

typedef void (*funptr)(void);

typedef enum { UART_STATE_HEADER, UART_STATE_PAYLOAD } uart_rx_state_t;

static uart_rx_state_t uartState = UART_STATE_HEADER;
static uint16_t payloadLength = 0;

static uint32_t bytesReceived = 0;
static uint32_t bytesRemaining = 0;

void init_uart() {
  CacheP_wbInv((void *)&gUartReceiveBuffer[0U], APP_UART_RECEIVE_BUFSIZE,
               CacheP_TYPE_ALL);

  UART_Transaction_init(&transRx);

  transRx.buf = &gUartReceiveBuffer[0];
  transRx.count = HEADER_SIZE;

  uartState = UART_STATE_HEADER;

  UART_read(gUartHandle[CONFIG_UART_CONSOLE], &transRx);
}

void uart_test(void *args) {
  int32_t transferOK;
  UART_Transaction_init(&transRx);

  if (rxcomplete == 1) {
  }
}

void RxCallback(UART_Handle handle, UART_Transaction *transaction) {
  if (transaction->status != UART_TRANSFER_STATUS_SUCCESS) return;

  CacheP_wbInv((void *)&gUartReceiveBuffer[0U], APP_UART_RECEIVE_BUFSIZE,
               CacheP_TYPE_ALL);

  if (uartState == UART_STATE_HEADER) {
    uint16_t payloadLength = ((uint16_t)gUartReceiveBuffer[2] << 8) |
                             (uint16_t)gUartReceiveBuffer[3];

    uartState = UART_STATE_PAYLOAD;

    UART_Transaction_init(&transRx);
    transRx.buf = &gUartReceiveBuffer[0];
    transRx.count = payloadLength + HEADER_SIZE + 5;

    UART_read(handle, &transRx);
  } else {
    /* Full frame received */

    uartState = UART_STATE_HEADER;

    UART_Transaction_init(&transRx);
    transRx.buf = &gUartReceiveBuffer[0];
    transRx.count = HEADER_SIZE;

    UART_read(handle, &transRx);
  }
}

这是我的 main.c

/*
 *  Copyright (C) 2018-2022 Texas Instruments Incorporated
 *
 *  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.
 */

#include <stdlib.h>
#include "ti_drivers_config.h"
#include "ti_board_config.h"

void uart_echo_dma(void *args);

int main(void)
{
    System_init();
    Board_init();
    Drivers_open();
    Board_driversOpen();


    init_uart();

    while(1)
    {
      uart_test(NULL);
    }

    Board_deinit();
    System_deinit();

    return 0;
}

要求

我的接收长度是动态的:

  • 首先、I 接收 4 个字节(标头)。

  • 第 2 个字节和第 3 个字节决定有效载荷长度。

  • 在此基础上,我更新 UART_Transaction.count.

  • 然后我 UART_read() 再次调用以接收剩余的有效负载。

  • 有效载荷接收完成后、我重新启动下一个 4 字节标头的接收。

来自外部器件的传入数据流是连续的。

我的数据不是静态的、它是数据的动态大小第一个数据决定了第二个传入数据的大小

发现的问题:
DMA 中断仅生成一次、然后不再发生中断  

请优先帮助

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

    您好:

    请注意、我们不能代表您调试代码;我们希望您调试应用级代码。

    这是我以前的主题、尚未解决、但你们大多数时间都是自己关闭 TT、为什么?

    我们不会关闭该主题、您始终可以通过点击此链接打开该主题、但无法解决我的问题