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.

CC3200 用UART DMA接收串口数据时,每次读到的最后一个字节都为0

Other Parts Discussed in Thread: CC3200

问题:我用串口调试助手往CC3200发送一组十六进制数,如“12 CA 35 FD 56 AC B4 67 89 BF DE EA AD”,但收到的buf为“12 CA 35 FD 56 AC B4 67 89 BF DE EA 0”,也就是最后一个字节丢了。发送其他长度的数据也同样会丢失最后一字节。

代码:

/*********************UartDMAInit***********************/
void UartDMAInit(void)
{
  //
  // Configure the UART Tx and Rx FIFO level to 1/8 i.e 2 characters
  //
  UARTFIFOLevelSet(UARTA1_BASE,UART_FIFO_TX1_8,UART_FIFO_RX1_8);
  
  //
  // Register interrupt handler for UART
  //
  osi_InterruptRegister(INT_UARTA1, UartDMAHandler, INT_PRIORITY_LVL_1);

  //
  // Enable DMA done interrupts for uart
  //
  MAP_UARTIntEnable(UARTA1_BASE, UART_INT_DMARX | UART_INT_DMATX);//UART_INT_RX
  
  //
  // Initialising the Terminal.
  //
  MAP_UARTConfigSetExpClk(UARTA1_BASE, MAP_PRCMPeripheralClockGet(PRCM_UARTA1), \
                  UART_BAUD_RATE, (UART_CONFIG_WLEN_8 |  \
                  UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); 
    
}
/*********************UartDMAReceive***********************/
int UartDMAReceive(const char* Rxbuf)
{
    int uint = 0;    
      
    do
    {
      UartDMAReceiveUnit(Rxbuf+uint*RECEIVE_LENGTH, RECEIVE_LENGTH, uint);  //RECEIVE_LENGTH = 1
      if(!user.RxDone)
      {
        break;
      }
    }while(++uint*RECEIVE_LENGTH <= 1024);
       
    return (1+uint)*RECEIVE_LENGTH;
}
/*********************UartDMAReceiveUnit***********************/
static void UartDMAReceiveUnit(const char* Rx_buf, int len, int cnt)
{
    //
    // Setup DMA transfer for UART A1
    //
    UDMASetupTransfer(UDMA_CH10_UARTA1_RX,
                      UDMA_MODE_BASIC,
                      len,
                      UDMA_SIZE_8,
                      UDMA_ARB_1,
                      (void *)(UARTA1_BASE+UART_O_DR),
                      UDMA_SRC_INC_NONE,
                      (void *)Rx_buf,
                      UDMA_DST_INC_8);
    
    //
    // Enable Rx DMA request from UART
    //
    MAP_UARTDMAEnable(UARTA1_BASE,UART_DMA_RX);
     
#if CLOSSE_POWER_SLEEP
    WAITTING_UART_RX;
#else
    if(cnt==0)
    {
      WAITTING_UART_RX_DATA;
    }
    else
    {
      WAITTING_UART_RX;
    }
#endif
    
    MAP_UARTDMADisable(UARTA1_BASE,UART_DMA_RX);    
    MAP_UARTIntClear(UARTA1_BASE,UART_DMA_RX); 
}