新唐M482SIDAE
芯片发送一组pu8TxBuf[10] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
通过串口调试助手接收到的数据为
我用USB-TTL,直接与PA.8、PA.9、GND相连
不知道为什么会这样,请各位大神指教。
代码如下:
#include "stdio.h"
#include "NuMicro.h"
#define PLL_CLOCK 192000000
#define RXBUFSIZE 1024
void SYS_Init(void)
{
/* Set XT1_OUT(PF.2) and XT1_IN(PF.3) to input mode */
PF->MODE &= ~(GPIO_MODE_MODE2_Msk | GPIO_MODE_MODE3_Msk);
/* Enable HXT clock (external XTAL 12MHz) */
CLK_EnableXtalRC(CLK_PWRCTL_HXTEN_Msk);
/* Wait for HXT clock ready */
CLK_WaitClockReady(CLK_STATUS_HXTSTB_Msk);
/* Set core clock as PLL_CLOCK from PLL */
CLK_SetCoreClock(PLL_CLOCK);
CLK->PCLKDIV = (CLK_PCLKDIV_APB0DIV_DIV2 | CLK_PCLKDIV_APB1DIV_DIV2); // PCLK divider set 2
/* Enable UART module clock */
CLK_EnableModuleClock(UART1_MODULE);
CLK_EnableModuleClock(UART2_MODULE);
/* Select UART clock source is HXT */
CLK->CLKSEL1 = (CLK->CLKSEL1 & ~CLK_CLKSEL1_UART1SEL_Msk) | (0x0 << CLK_CLKSEL1_UART1SEL_Pos);
/* Set GPA multi-function pins for UART1 RXD and TXD */
SYS->GPA_MFPH &= ~(SYS_GPA_MFPH_PA8MFP_Msk | SYS_GPA_MFPH_PA9MFP_Msk);
SYS->GPA_MFPH |= (SYS_GPA_MFPH_PA8MFP_UART1_RXD | SYS_GPA_MFPH_PA9MFP_UART1_TXD);
}
void UART1_Init()
{
SYS_ResetModule(UART1_RST);
/* Configure UART1 and set UART1 baud rate */
UART_SetLineConfig(UART1, 115200, UART_WORD_LEN_8, UART_PARITY_NONE, UART_STOP_BIT_1);
}
void Delay(int count)
{
int32_t a;
for ( ; count>0; count--)
for (a = 0; a < 1000; a++);
}
/*---------------------------------------------------------------------------------------------------------*/
/* UART Test Sample */
/* Test Item */
/* It sends the received data to HyperTerminal. */
/*---------------------------------------------------------------------------------------------------------*/
int32_t main(void)
{
uint8_t pu8TxBuf[10] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
/* Unlock protected registers */
SYS_UnlockReg();
/* Init System, peripheral clock and multi-function I/O */
SYS_Init();
/* Lock protected registers */
SYS_LockReg();
/* Init UART0 for printf and test */
UART1_Init();
while(1)
{
UART_Write(UART1, pu8TxBuf, 10);
Delay(60000);
}
}
|