您好! 我用的是一块,别人送我的STR7的核心板.外部晶振4MHz. 使用的环境是KEIL 的MDK3.51版本。
现在运行KEIL自带的 KEIL/ARM/BOARDS/HITEX/ST_HELLO 程序,发现实际的波特率只有设定的1/4...
到底是哪里错了呢,请老大们赐教。
以下是main程序。
#include "71x_lib.h"
#define UART0_Rx_Pin (0x0001<<8) /* TQFP 64: pin N?63 , TQFP 144 pin N?143 */ #define UART0_Tx_Pin (0x0001<<9) /* TQFP 64: pin N?64 , TQFP 144 pin N?144 */
#define UART1_Rx_Pin (0x0001<<10) /* TQFP 64: pin N?1 , TQFP 144 pin N?1 */ #define UART1_Tx_Pin (0x0001<<11) /* TQFP 64: pin N?2 , TQFP 144 pin N?3 */
#define UART2_Rx_Pin (0x0001<<13) /* TQFP 64: pin N?5 , TQFP 144 pin N?9 */ #define UART2_Tx_Pin (0x0001<<14) /* TQFP 64: pin N?6 , TQFP 144 pin N?10 */
#define UART3_Rx_Pin (0x0001<<1) /* TQFP 64: pin N?52 , TQFP 144 pin N?123 */ #define UART3_Tx_Pin (0x0001<<0) /* TQFP 64: pin N?53 , TQFP 144 pin N?124 */
#define Use_UART3 //#define Use_UART1 //#define Use_UART2 //#define Use_UART3
#ifdef Use_UART0 #define UARTX UART0 #define UARTX_Rx_Pin UART0_Rx_Pin #define UARTX_Tx_Pin UART0_Tx_Pin #define UARTX_Periph UART0_Periph #endif /* Use_UART0 */
#ifdef Use_UART1 #define UARTX UART1 #define UARTX_Rx_Pin UART1_Rx_Pin #define UARTX_Tx_Pin UART1_Tx_Pin #define UARTX_Periph UART1_Periph #endif /* Use_UART1 */
#ifdef Use_UART2 #define UARTX UART2 #define UARTX_Rx_Pin UART2_Rx_Pin #define UARTX_Tx_Pin UART2_Tx_Pin #define UARTX_Periph UART2_Periph #endif /* Use_UART2 */
#ifdef Use_UART3 #define UARTX UART3 #define UARTX_Rx_Pin UART3_Rx_Pin #define UARTX_Tx_Pin UART3_Tx_Pin #define UARTX_Periph UART3_Periph #endif /* Use_UART3 */
u16 i; u16 UARTStatus; u8 bBuffer[4] = {'t','e','s','t'}; /* Example 1 */ int main(void) { #ifdef DEBUG debug(); #endif
/* UART configuration ---------------------------------------------------------- */ /* Configure the GPIO pins as alternate function push pull */ GPIO_Config(GPIO0,UARTX_Tx_Pin, GPIO_AF_PP); /* Configure the GPIO pins as Input Tristate CMOS */ GPIO_Config(GPIO0,UARTX_Rx_Pin, GPIO_IN_TRI_CMOS);
/* Configure the UART X --------------------------------------------------------*/ /* Turn UARTX on */ UART_OnOffConfig(UARTX, ENABLE);
/* Disable FIFOs */ UART_FifoConfig (UARTX, DISABLE);
/* Reset the UART_RxFIFO */ UART_FifoReset(UARTX, UART_RxFIFO);
/* Reset the UART_TxFIFO */ UART_FifoReset(UARTX, UART_TxFIFO);
/* Disable Loop Back */ UART_LoopBackConfig(UARTX, DISABLE); /* Configure the UARTX as following: - Baudrate = 9600 Bps - No parity - 8 data bits - 1 stop bit */ UART_Config(UARTX, 9600, UART_NO_PARITY, UART_1_StopBits, UARTM_8D); /* Enable Rx */ UART_RxConfig(UARTX, ENABLE);
while(1) { for(i=0; i<4; i++) UART_ByteSend(UARTX,(u8 *)&bBuffer);
} }
|