apm32f030C8T6 官方uart 中断例程
串口原来是com1可以用,改换为com2不能使用
GPIO_Config_T gpioConfig;
USART_Config_T usartConfigStruct;
/* Enable GPIO clock */
RCM_EnableAHBPeriphClock( MINI_COM2_TX_GPIO_CLK);//MINI_COM1_TX_GPIO_CLK |
/* Enable COM1 or COM2 clock */
// RCM_EnableAPB2PeriphClock(MINI_COM1_CLK);
RCM_EnableAPB2PeriphClock(MINI_COM2_CLK);
/* Connect PXx to USARTx_Tx */
GPIO_ConfigPinAF(MINI_COM2_TX_GPIO_PORT, MINI_COM2_TX_SOURCE, MINI_COM2_TX_AF);
/* Connect PXx to USARRX_Rx */
GPIO_ConfigPinAF(MINI_COM2_RX_GPIO_PORT, MINI_COM2_RX_SOURCE, MINI_COM2_RX_AF);
/* Configure USART Tx as alternate function push-pull */
gpioConfig.mode = GPIO_MODE_AF;
gpioConfig.pin = MINI_COM2_TX_PIN;
gpioConfig.speed = GPIO_SPEED_50MHz;
gpioConfig.outtype = GPIO_OUT_TYPE_PP;
gpioConfig.pupd = GPIO_PUPD_PU;
GPIO_Config(MINI_COM2_TX_GPIO_PORT, &gpioConfig);
/* Configure USART Rx as input floating */
gpioConfig.pin = MINI_COM2_RX_PIN;
GPIO_Config(MINI_COM2_RX_GPIO_PORT, &gpioConfig);
/* MINI_USARTs configured as follow: */
/* BaudRate = 115200 baud */
usartConfigStruct.baudRate = 115200;
/* Receive and transmit enabled */
usartConfigStruct.mode = USART_MODE_TX_RX;
/* Hardware flow control disabled (RTS and CTS signals) */
usartConfigStruct.hardwareFlowCtrl = USART_FLOW_CTRL_NONE;
/* No parity */
usartConfigStruct.parity = USART_PARITY_NONE;
/* One Stop Bit */
usartConfigStruct.stopBits = USART_STOP_BIT_1;
/* Word Length = 8 Bits */
usartConfigStruct.wordLength = USART_WORD_LEN_8B;
/* USART_Config */
USART_Config(MINI_COM2, &usartConfigStruct);
/* Enable USART_Interrupt_RXBNEIE */
USART_EnableInterrupt(MINI_COM2, USART_INT_RXBNEIE);
NVIC_EnableIRQRequest(MINI_COM2_IRQn, 2);
/* Enable USART */
USART_Enable(MINI_COM2);
/* MINI_COM1 Send data to PC, and you need to open serial assistant to observe */
USART_Write(MINI_COM2, "HELLO APM MINI BOARD\r\n");
while (1)
{