|
每次接受到的数据都跟我传进来的不同,每次发送出去的也是乱码,可是我觉得我初始化里面没错呀!大虾帮我看看:
#define GetSystemClock() (80000000ul)
#define GetPeripheralClock() (GetSystemClock() / (1<
#define GetInstructionClock() (GetSystemClock())
#define DESIRED_BAUDRATE (9600)
SYSTEMConfig(GetSystemClock(), SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);
UARTConfigure(UART1, UART_ENABLE_PINS_TX_RX_ONLY );
UARTSetFifoMode(UART1, UART_INTERRUPT_ON_TX_NOT_FULL | UART_INTERRUPT_ON_RX_NOT_EMPTY);
UARTSetLineControl(UART1, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1);
UINT BD;
BD =UARTSetDataRate(UART1, GetPeripheralClock(), DESIRED_BAUDRATE);
UARTEnable(UART1, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX));
INTEnable(INT_SOURCE_UART_RX(UART1), INT_ENABLED);
INTSetVectorPriority(INT_VECTOR_UART(UART1), INT_PRIORITY_LEVEL_2);
INTSetVectorSubPriority(INT_VECTOR_UART(UART1), INT_SUB_PRIORITY_LEVEL_0);
// configure for multi-vectored mode
INTConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR);
// enable interrupts
INTEnableInterrupts();
应该没问题吧,我找了好久都没找出问题的根源,不知道如何解决乱码。 |
|