新手上路
- 积分
- 47
- 金钱
- 47
- 注册时间
- 2014-12-18
- 在线时间
- 0 小时
|
5金钱
串口初始化中已经有优先级配置,为啥main()函数中还要有个
NVIC_Configuration();中断优先级配置 作用是啥。感觉像多此一举。
void uart2_init(u32 bound)
|
053
|
GPIO_InitTypeDef GPIO_InitStructure;
|
054
|
USART_InitTypeDef USART_InitStructure;
|
055
|
NVIC_InitTypeDef NVIC_InitStructure;
|
057
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
|
058
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);
|
059
|
USART_DeInit(USART2);
|
060
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; //PA.9
|
061
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
062
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //??????
|
063
|
GPIO_Init(GPIOA, &GPIO_InitStructure); //???PA9
|
066
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
|
067
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
|
068
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
072
|
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;//串口初始化配置中优先级
|
073
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=3 ;
|
074
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;
|
075
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
076
|
NVIC_Init(&NVIC_InitStructure);
|
080
|
USART_InitStructure.USART_BaudRate = bound;
|
081
|
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
082
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
083
|
USART_InitStructure.USART_Parity = USART_Parity_No;
|
084
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
085
|
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
|
087
|
USART_Init(USART2, &USART_InitStructure); //?????
|
088
|
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);//????
|
089
|
USART_Cmd(USART2, ENABLE); //????
|
主函数
50
|
delay_init(); //???????
|
51
|
NVIC_Configuration(); //中断优先级配置,此处的作用什么什么
|
??????????????????????????????????????????????????????????????
52
|
uart_init(9600); //??????9600
|
哪位大侠指点一下?????????????????????????????????
|
最佳答案
查看完整内容[请看2#楼]
NVIC_Configuration是配置分组用的。
NVIC_Init!=NVIC_Configuration。得搞清楚。
|