拿到一块GD32F130G8U6的板子,USART1没啥问题,USART2(PA8 TX,PB0 RX)死活不能用。用IAR调试的,设备选的STM32F100C8,HSE_STARTUP_TIMEOUT改成了0XFFFF。
求助!!
=================================================================
RCC_AHBPeriphClockCmd( RCC_AHBPeriph_GPIOA , ENABLE );
RCC_AHBPeriphClockCmd( RCC_AHBPeriph_GPIOB , ENABLE );
RCC_APB2PeriphClockCmd( RCC_APB1Periph_USART2 , ENABLE );
GPIO_DeInit( GPIOA );
GPIO_DeInit( GPIOB );
{
/* Configure the GPIO ports */
GPIO_InitTypeDef GPIO_InitStructure;
/* Connect pin to Periph */
GPIO_PinAFConfig( GPIOA , GPIO_PinSource8, GPIO_AF_4 );
GPIO_PinAFConfig( GPIOB , GPIO_PinSource0, GPIO_AF_4 );
/* Configure pins as AF pushpull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init( GPIOA , &GPIO_InitStructure);
/* Configure pins as AF pushpull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init( GPIOB , &GPIO_InitStructure);
}
{
USART_InitTypeDef USART_InitStructure;
USART_DeInit( USART2);
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART2, &USART_InitStructure);
}
/* USART enable */
USART_Cmd(USART2, ENABLE);
printf("abc");
================================================================= |