新手入门
- 积分
- 14
- 金钱
- 14
- 注册时间
- 2020-10-30
- 在线时间
- 6 小时
|
8金钱
本帖最后由 anven 于 2021-1-7 15:54 编辑
为啥 代码里 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);不识别。


源码如下:
照抄串口视频的代码
- #include "stm32f0xx.h"
- #include <stdio.h>
- void My_USART_Init(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- //使能GPIOA时钟
- RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,ENABLE);
-
- GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_1);
- GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_1);
-
- /* Configure pins as AF pushpull */
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10;
- 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);
-
-
-
-
- USART_InitTypeDef USART_InitStructure;
- //使能串口时钟
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);
-
- /*设置串口硬件参数 */
- USART_DeInit(USART1);
- USART_InitStructure.USART_BaudRate = 4800;
- 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(USART1, &USART_InitStructure);
- /* 使能串口 */
- USART_Cmd(USART1, ENABLE);
-
- //* 使能串口接收中断 */
- USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
-
-
- NVIC_InitTypeDef NVIC_InitStructure;
- /* Enable the USART1 Interrupt */
- NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
- NVIC_InitStructure.NVIC_IRQChannelPriority = 0;
- NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
- NVIC_Init(&NVIC_InitStructure);
- }
-
- void USART1_IRQHandler(void)
- {
- uint8_t res;
- if(USART_GetITStatus(USART1, USART_IT_RXNE))
- {
- res = USART_ReceiveData(USART1);
- USART_SendData(USART1,res);
- }
- }
- int main(void)
- {
-
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
- My_USART_Init();
- while(1)
- {
-
- }
- }
复制代码
|
-
-
|