407英文简介的第46页说明63(PC6)、64(PC7)是USART6的输出引脚,但是配置后能进入发送中断引脚没有输出信号,而USART1~USART5都工作正常。
void Uart6_Configuration(void)
{
#if(COM6)
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
USART_ClockInitTypeDef USART_ClockInitStruct;
NVIC_InitTypeDef NVIC_InitStructure;
USART_DeInit(USART6);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6,ENABLE); //ʹÄÜUART6ʱÖÓ
NVIC_InitStructure.NVIC_IRQChannel = USART6_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; //ÇÀռʽÓÅÏȼ¶
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC,ENABLE); //ʹÄܶ˿ÚCʱÖÓ
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; //GPIOģʽ
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz; //GPIOËÙ¶È
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //GPIOÊä³öÀàÐÍ
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; //GPIOÉÏÀ¡¢ÏÂÀ¡¢²»À
GPIO_Init(GPIOC, &GPIO_InitStructure); //PC6-TXD6
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; //GPIOģʽ
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz; //GPIOËÙ¶È
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //GPIOÊä³öÀàÐÍ
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; //GPIOÉÏÀ¡¢ÏÂÀ¡¢²»À
GPIO_Init(GPIOC, &GPIO_InitStructure); //PC7-RXD6ΪÍÆÍ츴ÓÃÊä³ö
GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_USART6);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_USART6);
USART_InitStructure.USART_BaudRate = Uart6.BaudRate;
USART_InitStructure.USART_WordLength = (COM6_WordLen/9) << 12;
if(Uart6.CheckModle) //ÓÐУÑé
{
USART_InitStructure.USART_Parity = 1 << 10;
USART_InitStructure.USART_Parity |= (Uart6.CheckModle-1) << 9;
}
else //ÎÞУÑé
{
USART_InitStructure.USART_Parity = USART_InitStructure.USART_Parity & (~(1 << 10));
}
USART_InitStructure.USART_StopBits = COM6_StopBit << 12;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_HardwareFlowControl |= COM6_RTSE<<8;
USART_InitStructure.USART_HardwareFlowControl |= COM6_CTSE<<9;
USART_InitStructure.USART_HardwareFlowControl |= COM6_CTSIE<<10;
USART_InitStructure.USART_Mode = (COM6_RxEn<<2) | (COM6_TxEn<<3);
USART_Init(USART6, &USART_InitStructure);
USART6->BRR=ComputeUsartBRR(APB2CLK,Uart6.BaudRate,COM6_OVER8);
if(COM6_DMAT)
{
USART6->CR2 |= COM6_DMAT << 7;
}
if(COM6_DMAR)
{
USART6->CR2 |= COM6_DMAR << 6;
}
USART6->CR2 |= COM6_CLKEN << 11;
USART6->CR2 |= COM6_CPOL << 10;
USART6->CR2 |= COM6_CPHA << 9;
USART6->CR2 |= COM6_LBCL << 8;
USART6->CR1 &= ~(COM6_TxEIE << 7);
USART6->CR1 |= COM6_RxNEIE << 5;
USART6->CR1 |= COM6 << 13;
Uart6.TxdCnt=Uart6.TxdLen=0;
Uart6.RxdCnt=Uart6.RxdTimer=Uart6.Rxd=0;
#endif
}
|