NVIC_Configuration 中使能SysTick_IRQn

void NVIC_Configuration(void)
{
  NVIC_InitTypeDef NVIC_InitStructure;


#ifdef  VECT_TAB_RAM  
  /* Set the Vector Table base location at 0x20000000 */ 
  NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0); 
#else  /* VECT_TAB_FLASH  */
  /* Set the Vector Table base location at 0x08000000 */ 
  NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);   
#endif


  /* Enable the USART1 Interrupt */
  NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQChannel;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

 /* Enable the USART2 Interrupt */
  NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQChannel;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);


#if 1 // add liuxd 
  /* Enable the USART3Interrupt */
  NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQChannel; // USART3_IRQn; // USART3_IRQChannel;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
  #endif


  #if 0 // add liuxd 
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_3);   //选择分组3  3bits抢占优先级
  NVIC_InitStructure.NVIC_IRQChannel = SysTick_IRQChannel;// SysTick_IRQn;//中断号   
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;//抢占优先级   
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;   //子优先级     
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;       //使能中断
  NVIC_Init(&NVIC_InitStructure);
  #endif


}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
为下面每一行代码添加注释:#include "stm32f10x.h" void RCC_Configuration(void) { /* Enable GPIOA, GPIOC and AFIO clocks / RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE); / Enable SYSCFG clock / RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); } void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; / Configure PA0 pin as input floating / GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure); / Configure PC13 pin as output push-pull / GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOC, &GPIO_InitStructure); } void NVIC_Configuration(void) { NVIC_InitTypeDef NVIC_InitStructure / Configure the NVIC Preemption Priority Bits / NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); / Enable the EXTI0 Interrupt / NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } void EXTI_Configuration(void) { EXTI_InitTypeDef EXTI_InitStructure; / Configure EXTI Line0 to generate an interrupt on falling edge / EXTI_InitStructure.EXTI_Line = EXTI_Line0; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); / Connect EXTI Line0 to PA0 pin / GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource0); } void SysTick_Configuration(void) { / Configure SysTick to generate an interrupt every 1ms / if (SysTick_Config(SystemCoreClock / 1000)) { / Capture error / while (1); } } void Delay(__IO uint32_t nTime) { / Wait for nTime millisecond / TimingDelay = nTime; while (TimingDelay != 0); } void TimingDelay_Decrement(void) { if (TimingDelay != 0x00) { TimingDelay--; } } int main(void) { RCC_Configuration(); GPIO_Configuration(); NVIC_Configuration(); EXTI_Configuration(); SysTick_Configuration(); / Infinite loop / while (1) { / Toggle PC13 LED every 500ms / GPIOC->ODR ^= GPIO_Pin_13; Delay(500); } } void EXTI0_IRQHandler(void) { / Check if PA0 button is pressed / if (GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0) == RESET) { / Reset MCU / NVIC_SystemReset(); } / Clear EXTI Line0 pending bit */ EXTI_ClearITPendingBit(EXTI_Line0); }
最新发布
06-03
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值