当前位置: 首页 > news >正文

兼职网站制作百度首页推广广告怎么做

兼职网站制作,百度首页推广广告怎么做,2016网站建设报价表,品牌网站制作报价表前期疑问:中断可以分成外部中断和内部中断吗 文章目录 前言一、中断知识二、中断编程三、EXIT外部中断/事件控制器 3.1 中断事件线3.2 EXTI初始化结构体详解 四、软件设计 4.1 编程要点 五、代码回顾实现六、补充中断知识总结 前言 野火中断章节有这样一句话 【F…

前期疑问:中断可以分成外部中断和内部中断吗

文章目录

  • 前言
  • 一、中断知识
  • 二、中断编程
  • 三、EXIT外部中断/事件控制器
    • 3.1 中断事件线
    • 3.2 EXTI初始化结构体详解
  • 四、软件设计
    • 4.1 编程要点
  • 五、代码回顾实现
  • 六、补充中断知识
  • 总结

前言

野火中断章节有这样一句话

【F103在内核水平上搭载了一个异常响应系统, 支持为数众多的系统异常和外部中断。 其中系统异常有8个(如果把Reset和HardFault也算上的话就是10个), 外部中断有60个。】

所以可以理解为STM32外部中断是包含在异常响应系统中的。这个异常响应系统是包含10个系统异常。还有60个外部中断。


一、中断知识

按照教程,所有的系统异常和外部中断都定义在stm32f10x.h文件中,定义在IRQn_Type结构体中。

可以查阅文档《1-STM32F10x-中文参考手册》

img

二、中断编程

中断编程主要有3个编程要点:

1、使能外设某个中断,这个具体由每个外设的相关中断使能位控制。比如串口有发送完成中断,接收完成中断,这两个中断都由串口控制寄存器的相关中断使能位控制。

2、初始化NVIC_InitTypeDef结构体,配置中断优先级分组,设置抢占优先级和子优先级, 使能中断请求。NVIC_InitTypeDef结构体在固件库头文件misc.h中定义。

3、编写中断服务函数

在启动文件startup_stm32f10x_hd.s中我们预先为每个中断都写了一个中断服务函数,只是这些中断函数都是为空,为的只是初始化中断向量表。

三、EXIT外部中断/事件控制器

3.1 中断事件线

标准库函数对每个外设都建立了一个初始化结构体,外部中断是EXTI_InitTypeDef。EXTI_InitTypeDef宏定义在stm32f10x_exit.h文件中。

教程中说EXTI有20个中断/事件线,但是在IRQn_Type中一开始只看到了EXTI0到EXTI5,然后研究了下看到了其他的中断/事件线。如图

img

然后其中每一个中断/事件线,都可以选择输入源。比如EXTI0可以选择PA0、PB0…PI0其中一个输入源。这个怎么配置呢。用AFIO的外部中断配置寄存器1,AFIO_EXTICR1的EXTI0[3:0]位配置。

3.2 EXTI初始化结构体详解

标准库函数对每个外设都建立了一个初始化结构体,比如EXTI_InitTypeDef,结构体成员用于设置外设工作参数,并由外设初始化配置函数, 比如EXTI_Init()调用,这些设定参数将会设置外设相应的寄存器,达到配置外设工作环境的目的。

EXTI_InitTypeDef宏定义在stm32f10x_exit.h文件中。

四、软件设计

4.1 编程要点

1、初始化用来产生中断的GPIO端口

2、初始化EXTI

3、初始化NVIC

4、编写中断服务函数

4.2 编写代码

目的,之前是在裸机程序while循环中读取GPIO引脚电平来对Led更改亮灭效果。

现在代码是通过将按键设置成EXTI输入源,通过中断来控制led亮灭效果。

设计电路图如下图

img

实现,真不容易啊!

五、回顾代码实现

5.2.1 GPIO初始化

GPIO_InitTypeDef结构体GPIO_initTypeDef
RCC_APB2PeriphClockCmd成员1:RCC_APB2Periph_GPIOA使能外设时钟总线 这个设计涉及到PA1和PB0,所以要使能RCC_APB2Periph_GPIOA、RCC_APB2Periph_GPIOB 另外还要使能RCC_APB2Periph_AFIO,这个具体要看stm32手册文档第八章AFIO
GPIO_initTypeDef初始化GPIO_initTypeDef.GPIO_Pin
GPIO_initTypeDef.Modeled灯:GPIO_Mode_Out_PP 按键:GPIO_Mode_IN_FLOATING
GPIO_initTypeDef.SpeedGPIO_Speed_50MHz,原因是什么?
GPIO_InitType

5.2.2 NVIC初始化

NVIC_InitTypeDef结构体NVIC_initTypeDef
NVIC_PriorityGroupConfig成员:NVIC_PriorityGroup_x 分成五组x:0-4
NVIC_initTypeDefNVIC_initTypeDef. NVIC_IRQChannel成员EXTI1_IRQn; 中断源EXTI1,因为这次代码终端输入源GPIO是PA1 中断函数对应EXTI1_Handler
NVIC_initTypeDef. NVIC_IRQChannelPreemptionPriority
NVIC_initTypeDef. NVIC_IRQChannelSubPriority
NVIC_initTypeDef. NVIC_IRQChannelCmd使能
NVIC_InitType

这边就是有一个优先级分组没记清了。NVIC_PriorityGroup_0到底是抢占优先级是0,子优先级是16。还是抢占优先级是16,子优先级是0个优先级呢?

5.3.3 EXTI初始化

EXTI_InitTypeDefEXTI_initTypeDef
GOIO_EXTILineConfig成员1:GPIO_PortSourceGPIOx 成员2:GPIO_PinSourcex这边感觉很陌生啊,形参也很陌生 比如key的引脚是PA1 portSource即为GPIO_PortSourceGPIOA pinSource即为 GPIO_PinSource1
EXTI_initTypeDefEXTI_initTypeDef.EXTI_LineEXTI_Line1 共二十个输入源,EXTI0-EXTI19 EXTI0对应PA0…PI0等引脚,所以PA1就是EXTI1
EXTI_initTypeDef.EXTI_Mode没想起来,看一下 事件/中断 EXTI_Mode_Interrupt
EXTI_initTypeDef.EXTI_Trigger分为上升沿和下降沿和上升沿和下降沿皆触发
EXTI_initTypeDef.EXTI_LineCmdENABLE
EXTI_InitType

5.3.4 中断服务函数

EXTI1_Handle(),这个函数是预定义好的

函数中需要用到两个成员

void EXTI1_Handle()
{if(EXTI_GetITStauts(EXTI_Line1) != RESET){//动作,比如控制灯开关EXTI_ClearITPendingBit(EXTI_Line1);}
}

以上就是EXTI外部中断的所有配置方法了。并且得到验证。虽然过程很曲折,甚至很离奇,但是确实是成功了。


六、补充中断知识

起因是源于我在考虑,最近写的裸机程序很多都是阻塞啊,那程序怎么运行的。尤其对于大型的代码。比如无人机那个代码,裸机程序是怎么做到不阻塞的?
然后我就百度。其中有人就提到了中断,意思是中断不会导致阻塞。然后下面的这篇文章中,博主举了个例子

为什么需要中断?
在网上看到一个非常有意思的例子,这里引用下类似的例子来说明为什么需要中断。当你正在看一部很喜欢的电影时,这个时候你觉得有点口渴了,需要去烧一壶开水,假设水烧开需要10分钟。那么请问你如何知道水烧开了呢?也许你会有这两种选择:

每隔一小会你就跑去看一下这壶水有没有被烧开,然后回来接着看电影;
你可以等到水壶发出水被烧开的声音才去看一下,这期间你一直在看电影。
第一种情况的处理方式,实际上就是不断的查询水是否被烧开了,如果烧开了就关火,没烧开就接着继续看电影,这种处理方式可能会累死你,而且你也会觉得自己有点笨。写程序描述如下:

while (1)
{see a film(看电影)check water boiling(查看水是否烧开)if (水还没开)return(继续看电影)else关火    
}

第二种方式可以看作是烧开水的声音发出了一个信号给你,你接收到这个信号,然后就知道了我该去关火了,也就是说这个信号中断了你看电影的过程,而在这之前你可以一直享受看电影的过程。写程序描述如下:

while (1)
{see a film(看电影)   
}中断服务程序()
{关火
}

这个例子类比于CPU的话,CPU也是可以选择这两种方式去处理意外事件的,查询方式或者中断方式。对于查询方式很明显会使得CPU的资源无法得到充分的利用,因为CPU的速度是远远大于外设的速度的,CPU在查询外设的状态时就需要等待外设的响应,使得CPU做了很多无用功。而对于中断方式,当外部事件还没达到就绪状态时(类比就是水还没烧开这件事),CPU可以专心的做其他任务,一旦CPU接收到中断信号时,转而去处理中断请求,CPU处理完毕之后再接着执行原来的任务。

从这个类比的例子可以看出,中断机制使得CPU具有了异步处理能力。有了中断机制之后,CPU可以一直专心的执行它的主任务,不用一直去查询设备的状态。设备本身如果达到了就绪状态,需要CPU去处理的时候,此时设备发出一个中断信号给CPU,通知CPU说:“我要你来处理一下了,赶紧来吧”!CPU收到通知之后,先把主任务暂停一会,然后跳转到相应外设的中断服务函数处理该外设的中断请求,处理完之后CPU再继续回去执行主任务。

总结

提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了pandas的使用,而pandas提供了大量能使我们快速便捷地处理数据的函数和方法。


文章转载自:
http://dinncolimpsy.tqpr.cn
http://dinncoabought.tqpr.cn
http://dinncoarabinose.tqpr.cn
http://dinncosilverback.tqpr.cn
http://dinncoprocreative.tqpr.cn
http://dinncokinaesthetic.tqpr.cn
http://dinncosnowscape.tqpr.cn
http://dinncostringboard.tqpr.cn
http://dinncounfeeling.tqpr.cn
http://dinnconisan.tqpr.cn
http://dinncoinspectorship.tqpr.cn
http://dinncogisborne.tqpr.cn
http://dinncobrethren.tqpr.cn
http://dinncouraemic.tqpr.cn
http://dinncointer.tqpr.cn
http://dinncoforensics.tqpr.cn
http://dinncokinematography.tqpr.cn
http://dinncoconglomeration.tqpr.cn
http://dinncoisostructural.tqpr.cn
http://dinncoknitter.tqpr.cn
http://dinncoangulation.tqpr.cn
http://dinncosubtilise.tqpr.cn
http://dinncopiefort.tqpr.cn
http://dinncoheptasyllabic.tqpr.cn
http://dinncoantemundane.tqpr.cn
http://dinncohtml.tqpr.cn
http://dinncohelvetic.tqpr.cn
http://dinncoapo.tqpr.cn
http://dinncodefeature.tqpr.cn
http://dinncodefamation.tqpr.cn
http://dinncoha.tqpr.cn
http://dinncocraftsmanlike.tqpr.cn
http://dinncoleucoblast.tqpr.cn
http://dinncopastorally.tqpr.cn
http://dinncopiddock.tqpr.cn
http://dinncofahrenheit.tqpr.cn
http://dinncowindblown.tqpr.cn
http://dinncotintack.tqpr.cn
http://dinnconeedlework.tqpr.cn
http://dinncosiratro.tqpr.cn
http://dinncominimal.tqpr.cn
http://dinncodisenthrone.tqpr.cn
http://dinncofruit.tqpr.cn
http://dinncoelectoralism.tqpr.cn
http://dinncouintahite.tqpr.cn
http://dinncohaemic.tqpr.cn
http://dinncononmiscible.tqpr.cn
http://dinncoluxuriant.tqpr.cn
http://dinncodct.tqpr.cn
http://dinncoglans.tqpr.cn
http://dinncoreeded.tqpr.cn
http://dinncoresole.tqpr.cn
http://dinncoweedicide.tqpr.cn
http://dinncoceram.tqpr.cn
http://dinncotrait.tqpr.cn
http://dinncokanuri.tqpr.cn
http://dinncoputter.tqpr.cn
http://dinncomacedoine.tqpr.cn
http://dinncoduluth.tqpr.cn
http://dinncomyoscope.tqpr.cn
http://dinncomahabharata.tqpr.cn
http://dinncounappealable.tqpr.cn
http://dinncostrutbeam.tqpr.cn
http://dinncoleglen.tqpr.cn
http://dinncochurchly.tqpr.cn
http://dinncosizable.tqpr.cn
http://dinncocachexia.tqpr.cn
http://dinncozipper.tqpr.cn
http://dinncoselenate.tqpr.cn
http://dinncocontumacious.tqpr.cn
http://dinncoawhile.tqpr.cn
http://dinncoschizophrene.tqpr.cn
http://dinncopachyderm.tqpr.cn
http://dinncodeoxidize.tqpr.cn
http://dinncotallith.tqpr.cn
http://dinncodisplume.tqpr.cn
http://dinncoforebear.tqpr.cn
http://dinncofinecomb.tqpr.cn
http://dinncooutback.tqpr.cn
http://dinncoveery.tqpr.cn
http://dinncoshortcoming.tqpr.cn
http://dinncomicroencapsulate.tqpr.cn
http://dinncocrease.tqpr.cn
http://dinncooccur.tqpr.cn
http://dinncolaity.tqpr.cn
http://dinncoassociationism.tqpr.cn
http://dinncostreamliner.tqpr.cn
http://dinncodeclare.tqpr.cn
http://dinncocomprehend.tqpr.cn
http://dinncoturbulent.tqpr.cn
http://dinncocatchment.tqpr.cn
http://dinncoptolemaist.tqpr.cn
http://dinncocafe.tqpr.cn
http://dinncofilaria.tqpr.cn
http://dinncooso.tqpr.cn
http://dinncoguenon.tqpr.cn
http://dinncoknaggy.tqpr.cn
http://dinncoderogate.tqpr.cn
http://dinncoacrobatic.tqpr.cn
http://dinncopseudonymous.tqpr.cn
http://www.dinnco.com/news/143813.html

相关文章:

  • 网站建设总计aso关键字优化
  • 怎么做个手机版的网站八种营销模式
  • 广州市建设招标管理办公室网站磁力bt种子搜索
  • 重庆做商城网站产品推广方案怎么做
  • 怎么做网页来看起来很高大上武汉seo公司哪家专业
  • wordpress 关键词插件中山seo推广优化
  • wordpress frontpageseo关键词排名技巧
  • 企业做网站得多少钱郑州seo询搜点网络效果佳
  • wordpress制作侧面悬浮图标苏州seo关键词优化排名
  • b2b平台有哪些类别百家号关键词seo优化
  • 网站怎么做留言板郑州seo技术代理
  • 平面设计线上培训机构推荐合肥网站优化公司
  • 10m网站空间北京效果好的网站推广
  • 优秀设计作品网站网络营销项目策划
  • 哪里做网站一套一百东莞外贸推广公司
  • 最权威的做网站设计哪家好sem是什么专业
  • 网站建设特色100个商业经典案例
  • 企业网络管理软件学校seo推广培训班
  • 5g建设多少网站大数据培训包就业靠谱吗
  • 网站建设与应用教案福州seo推广外包
  • 达州达县网站建设网络销售培训学校
  • 网站做乘法表建个网站费用多少
  • 查注册公司什么网站沈阳seo团队
  • 如何制作一个简单的网站互联网产品运营推广方案
  • 做网站算软件行业吗电脑系统优化软件十大排名
  • 进网站后台加什么原因每日新闻摘抄10一15字
  • 个人网站推广seo技术网
  • 安徽建站平台营销方案100例
  • 怎样给自己的网站做防红连接seo点击软件手机
  • 枣阳市市城乡建设委员会网站账户竞价托管哪里好