外部中断:
向量表:异常+中断
所有端口的PIN0对应着EXTI0中短线,PIN1对应EXTI1中断线,依次类推
16个外部中断线,对应7个外部中断入口地址
配置中断优先级的4位要同时完成抢占优先级和响应优先级(子优先级或副优先级)的配置:两组优先级
2+2,2^2抢占,2^2响应比较常用
使用NVIC_PriorityGroupConfig(NVIC_PriorityGroup_X)来设定
串口通信:
USART1_IRQHandler(void) 串口中断服务程序
void Serial_Init(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_Init(USART1, &USART_InitStructure);
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_Init(&NVIC_InitStructure);
USART_Cmd(USART1, ENABLE);
}
1 void USART1_IRQHandler(void) 2 { 3 if (USART_GetITStatus(USART1, USART_IT_RXNE) == SET) 4 { 5 Serial_RxData = USART_ReceiveData(USART1); 6 Serial_RxFlag = 1; 7 USART_ClearITPendingBit(USART1, USART_IT_RXNE); 8 } 9 }
定时器:计数频率,计数个数
看门狗:
窗口看门狗:采用系统时钟,监控软件的运行异常
独立看门狗:通过一个12bit的计数器对设定频率减计数,采用独立时钟,监控芯片异常
TRANSLATE with x English TRANSLATE with COPY THE URL BELOW Back EMBED THE SNIPPET BELOW IN YOUR SITE Enable collaborative features and customize widget: Bing Webmaster Portal Back 标签:定时器,USART,NVIC,STM23,InitStructure,Mode,串口,GPIO,USART1 From: https://www.cnblogs.com/ustc2122zy/p/17636372.html