CH32V307 UART3中斷接受多個(gè)16進(jìn)制數(shù)據(jù)時(shí)只能接受列表的第一個(gè),想要接收攝像頭模塊的返回?cái)?shù)據(jù),但是發(fā)現(xiàn)UART3每次只能接受攝像頭發(fā)送數(shù)據(jù)的第一個(gè)。同樣的UART以及NVIC中斷初始化在UART2中則不存在這個(gè)問題。不知道這是什么原因?qū)е碌?,求教?/p>
代碼如下:
void?USART3_Camera_Init(void) { ????uart_init(UART_3,?38400,?B10,?B11); ???? } void?USART3_Camera_Init_IT(void) { ????????????/*UART3輸入中斷使能*/ ????????????USART_ITConfig(USART3,?USART_IT_RXNE,?ENABLE);?????????????? ????????????/*NVIC配置*/ ????????????NVIC_InitTypeDef?NVIC_InitStructure;????????????????????????//定義結(jié)構(gòu)體變量 ????????????NVIC_InitStructure.NVIC_IRQChannel?=?USART3_IRQn;?????????????//選擇配置NVIC的USART1線 ????????????NVIC_InitStructure.NVIC_IRQChannelCmd?=?ENABLE;?????????????//指定NVIC線路使能 ????????????NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority?=?0;???//指定NVIC線路的搶占優(yōu)先級(jí)為0?比無線通訊搶占優(yōu)先級(jí)(2)高 ????????????NVIC_InitStructure.NVIC_IRQChannelSubPriority?=?0;??????????//指定NVIC線路的響應(yīng)優(yōu)先級(jí)為1 ????????????NVIC_Init(&NVIC_InitStructure);?????????????????????????????//將結(jié)構(gòu)體變量交給NVIC_Init,配置NVIC外設(shè) } //下面是UART2的初始化 void?UART1_HC14_Init(void) { ????uart_init(UART_1,?9600,?A9,?A10); } void?USART1_HC14_Init_IT(void) { ????????????/*UART1輸入中斷使能*/ ????????????USART_ITConfig(USART1,?USART_IT_RXNE,?ENABLE);?????????????? ????????????/*NVIC配置*/ ????????????NVIC_InitTypeDef?NVIC_InitStructure;????????????????????????//定義結(jié)構(gòu)體變量 ????????????NVIC_InitStructure.NVIC_IRQChannel?=?USART1_IRQn;?????????????//選擇配置NVIC的USART1線 ????????????NVIC_InitStructure.NVIC_IRQChannelCmd?=?ENABLE;?????????????//指定NVIC線路使能 ????????????NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority?=?1;???//指定NVIC線路的搶占優(yōu)先級(jí)為1?比臨時(shí)通訊搶占優(yōu)先級(jí)(2)高 ????????????NVIC_InitStructure.NVIC_IRQChannelSubPriority?=?1;??????????//指定NVIC線路的響應(yīng)優(yōu)先級(jí)為1 ????????????NVIC_Init(&NVIC_InitStructure);?????????????????????????????//將結(jié)構(gòu)體變量交給NVIC_Init,配置NVIC外設(shè) }
熱門產(chǎn)品 :
CH32V317: 互聯(lián)型青稞RISC-V MCU