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.

在SimpleBLEPeripheral工程里面添加USART 1初始化函数以后程序跑飞



我在SimpleBLEPeripheral工程里面添加USART 1初始化函数,但是添加上以后程序会跑飞,我检查串口初始化函数没有找到错,我用的是1.6和1.7管脚,但是1.4和1.5管脚用的是USART 0的SPI模式,这对程序有影响吗?谁在SimpleBLEPeripheral工程里面添加过初始化函数,能不能给个初始化例程做个参考

下面再贴上我的串口初始化程序,大家帮忙看看

void GPS_ConfigUART(void)
{
/* UART/SPI Peripheral configuration */

uint8 baud_exponent;
uint8 baud_mantissa;
CLKCONCMD&=~(1<<6);
while(CLKCONCMD&(1<<6));
CLKCONCMD&=~((1<<6)|(7<<0));

/* Set SPI on UART 0 alternative 2 */
PERCFG |= 0x02;
P1SEL|=0xc0;
P2SEL|=0x40;//优先级设置
baud_exponent = 8;
baud_mantissa = 59;
/* Configure SPI */
U1UCR = 0x80; /* Flush and goto IDLE state. 8-N-1. */
U1UCR = 0x02;
U1CSR |= 0xc0; /* UARTmode, */
U1GCR = baud_exponent;
U1BAUD = baud_mantissa;
URX1IE=1;
EA=1;
URX1IF=0;
}

  • /*uart初始化代码,配置串口的波特率、流控制等*/
    void serialAppInitTransport( )
    {
      halUARTCfg_t uartConfig;

      // configure UART
      uartConfig.configured           = TRUE;
      uartConfig.baudRate             = SBP_UART_BR;//波特率
      uartConfig.flowControl          = SBP_UART_FC;//流控制
      uartConfig.flowControlThreshold = SBP_UART_FC_THRESHOLD;//流控制阈值,当开启flowControl时,该设置有效
      uartConfig.rx.maxBufSize        = SBP_UART_RX_BUF_SIZE;//uart接收缓冲区大小
      uartConfig.tx.maxBufSize        = SBP_UART_TX_BUF_SIZE;//uart发送缓冲区大小
      uartConfig.idleTimeout          = SBP_UART_IDLE_TIMEOUT;
      uartConfig.intEnable            = SBP_UART_INT_ENABLE;//是否开启中断
      uartConfig.callBackFunc         = sbpSerialAppCallback;//uart接收回调函数,在该函数中读取可用uart数据

      
      // start UART
      // Note: Assumes no issue opening UART port.
      (void)HalUARTOpen( SBP_UART_PORT, &uartConfig );

      return;
    }
     

  • 可是我不用DMA的话是不是就不能用HalUARTOpen函数初始化串口?

  • HalUARTOpenDMA(config);

    HalUARTOpenISR(config);

    HalUARTOpenSPI(config);