昨天试着用了一下USART6,这好像跟其他串口一样吧,但是我配置完之后却进不去。按照论坛里搜到的那一份USART6配置[mw_shl_code=c,true]void USART6_Configuration(void)
{
USART_InitTypeDef usart6;
GPIO_InitTypeDef gpio;
NVIC_InitTypeDef nvic;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6,ENABLE);
GPIO_PinAFConfig(GPIOC,GPIO_PinSource6,GPIO_AF_USART6);
GPIO_PinAFConfig(GPIOC,GPIO_PinSource7,GPIO_AF_USART6);
gpio.GPIO_Pin = GPIO_Pin_6| GPIO_Pin_7;
gpio.GPIO_Mode = GPIO_Mode_AF;
gpio.GPIO_Speed = GPIO_Speed_100MHz;
gpio.GPIO_PuPd = GPIO_PuPd_NOPULL;
gpio.GPIO_OType = GPIO_OType_PP;
GPIO_Init(GPIOC, &gpio);
usart6.USART_BaudRate = 115200;
usart6.USART_WordLength = USART_WordLength_8b;
usart6.USART_StopBits = USART_StopBits_1;
usart6.USART_Parity = USART_Parity_No;
usart6.USART_Mode = USART_Mode_Rx|USART_Mode_Tx;
usart6.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_Init(USART6,&usart6);
USART_Cmd(USART6,ENABLE);
USART_ITConfig(USART6,USART_IT_RXNE,ENABLE);
nvic.NVIC_IRQChannel = USART6_IRQn;
nvic.NVIC_IRQChannelPreemptionPriority = 0;
nvic.NVIC_IRQChannelSubPriority = 2;
nvic.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&nvic);
}
uint8_t Raw_Data[72];
void USART6_IRQHandler(void)
{
if(USART_GetITStatus(USART6, USART_IT_RXNE) != RESET)
{
Raw_Data[counter] = USART_ReceiveData(USART6);
}
}[/mw_shl_code]o也没用。检查了好久,觉得没问题呀,可以帮忙看下嘛?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>