<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN">
		<id>http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Lesson_20--Microduino_%22Use_Interrupt%22</id>
		<title>Lesson 20--Microduino &quot;Use Interrupt&quot; - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Lesson_20--Microduino_%22Use_Interrupt%22"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Lesson_20--Microduino_%22Use_Interrupt%22&amp;action=history"/>
		<updated>2026-04-21T07:58:32Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Lesson_20--Microduino_%22Use_Interrupt%22&amp;diff=1211&amp;oldid=prev</id>
		<title>2014年3月2日 (日) 15:03 Pkj</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Lesson_20--Microduino_%22Use_Interrupt%22&amp;diff=1211&amp;oldid=prev"/>
				<updated>2014-03-02T15:03:53Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;zh-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;2014年3月2日 (日) 15:03的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;第1行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第1行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Language|&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Lesson_20&lt;/del&gt;--&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Microduino_&amp;quot;Use_Interrupt&amp;quot;&lt;/del&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Language|&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;第二十课&lt;/ins&gt;--&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Microduino_中断的使用&lt;/ins&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{| style=&amp;quot;width: 800px;&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{| style=&amp;quot;width: 800px;&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|-&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|-&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Pkj</name></author>	</entry>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Lesson_20--Microduino_%22Use_Interrupt%22&amp;diff=1170&amp;oldid=prev</id>
		<title>2014年3月2日 (日) 14:31 Pkj</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Lesson_20--Microduino_%22Use_Interrupt%22&amp;diff=1170&amp;oldid=prev"/>
				<updated>2014-03-02T14:31:39Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;zh-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;2014年3月2日 (日) 14:31的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;第1行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第1行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{Language|Lesson_20--Microduino_&amp;quot;Use_Interrupt&amp;quot;}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{| style=&amp;quot;width: 800px;&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{| style=&amp;quot;width: 800px;&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|-&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|-&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Pkj</name></author>	</entry>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Lesson_20--Microduino_%22Use_Interrupt%22&amp;diff=772&amp;oldid=prev</id>
		<title>Jasonsheng：Created page with &quot;{| style=&quot;width: 800px;&quot; |- | ==Objective== Understand the interruption, and through the button to learn the usage of the interrupt.  ==Interrupt== ===The basic principle of i...&quot;</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Lesson_20--Microduino_%22Use_Interrupt%22&amp;diff=772&amp;oldid=prev"/>
				<updated>2014-02-19T08:21:04Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{| style=&amp;quot;width: 800px;&amp;quot; |- | ==Objective== Understand the interruption, and through the button to learn the usage of the interrupt.  ==Interrupt== ===The basic principle of i...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{| style=&amp;quot;width: 800px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Objective==&lt;br /&gt;
Understand the interruption, and through the button to learn the usage of the interrupt.&lt;br /&gt;
&lt;br /&gt;
==Interrupt==&lt;br /&gt;
===The basic principle of interruption===&lt;br /&gt;
CPU is processing one event and interrupted by external another event, after when performing the external things, continue to do previous event. For example: the teacher in class, and a student enter the classroom suddenly interrupted the teacher, the teacher allow him into the classroom, and go on teaching, this is the interrupt.&lt;br /&gt;
&lt;br /&gt;
===Interrupt concept===&lt;br /&gt;
Interrupt that menas the CPU in the normal operation of the program, due to internal/external events or by program pre-arranged event which cause the CPU stop running applications, and transfer to another service for internal/external events or service for a pre-arranged event program. After finished that service, return to execute the temporarily interrupted program.&lt;br /&gt;
&lt;br /&gt;
Due to the occurrence of an event, the CPU suspended execution of a program, and then turn to process incoming event's program. &lt;br /&gt;
After complete this program, then CPU recover the suspended program. This process is called the interrupt.&lt;br /&gt;
&lt;br /&gt;
===Interrupt classification===&lt;br /&gt;
*The location of the interrupt source&lt;br /&gt;
**The interrupt source in the interior of the CPU, known as internal interrupt.&lt;br /&gt;
**The interrupt source in the outside of the CPU, known as external interrupt.&lt;br /&gt;
*According to interrupt pin or CPU interrupt response of different conditions: Maskable interrupt and nonmaskable interrupt.&lt;br /&gt;
&lt;br /&gt;
===Interrupt benefits===&lt;br /&gt;
*Improve the efficiency of the CPU by time sharing operation. Only when the service object sent a interrupt reques to CPU, then CPU will process it. So that we can use the interrupt function to support multiple objects at the same time, thus greatly improving the efficiency of the CPU.&lt;br /&gt;
*Use the interrupt to achieve real-time processing. The service object can send the CPU interrupt at any time, CPU can find and process interrupt request immediately.&lt;br /&gt;
&lt;br /&gt;
==Equipment==&lt;br /&gt;
'''[[Microduino-Core]]'''&lt;br /&gt;
'''[[Microduino-FT232R]]'''&lt;br /&gt;
*Other hardware equipment&lt;br /&gt;
**Breadboard Jumper            one box   &lt;br /&gt;
**Breadboard  	               one piece  &lt;br /&gt;
**LED                          one &lt;br /&gt;
**220Ω resistor     	         one &lt;br /&gt;
**USB Data cable               one&lt;br /&gt;
**Button                       one&lt;br /&gt;
&lt;br /&gt;
==Experimental schematic==&lt;br /&gt;
*'''Microduino core：two external interrupt，that are D2 and D3；'''&lt;br /&gt;
*'''Microduino core+：three external interrup，that are D2, D3 and D6。'''&lt;br /&gt;
[[File:lesson20-schematic.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Program==&lt;br /&gt;
*Don't use the external interrupt&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int button= 2;          // Define the input pin&lt;br /&gt;
int pin = 13;&lt;br /&gt;
volatile int state = LOW;&lt;br /&gt;
 &lt;br /&gt;
void setup()&lt;br /&gt;
{                &lt;br /&gt;
  //Set the input pin as input state and output pin as output state&lt;br /&gt;
  pinMode(button,INPUT); &lt;br /&gt;
  pinMode(pin,OUTPUT);&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
void loop()                     &lt;br /&gt;
{&lt;br /&gt;
  state = digitalRead(button);      //Read the button's state&lt;br /&gt;
 &lt;br /&gt;
  digitalWrite(ledOut, state);    //Set the state value to LED&lt;br /&gt;
 &lt;br /&gt;
  //Simulate a long time process or a complex task&lt;br /&gt;
  for (int i = 0; i &amp;lt; 100; i++)&lt;br /&gt;
  {&lt;br /&gt;
    delay(10); &lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Use the external interrupt&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int pin = 13;&lt;br /&gt;
volatile int state = LOW;&lt;br /&gt;
&lt;br /&gt;
void setup()&lt;br /&gt;
{&lt;br /&gt;
  pinMode(pin, OUTPUT);&lt;br /&gt;
  attachInterrupt(0, blink, RISING);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop()&lt;br /&gt;
{&lt;br /&gt;
  digitalWrite(pin, state);//Set the state value to LED&lt;br /&gt;
  //Simulate a long time process or a complex task&lt;br /&gt;
  for (int i = 0; i &amp;lt; 100; i++)&lt;br /&gt;
  {&lt;br /&gt;
    delay(10); &lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void blink()&lt;br /&gt;
{&lt;br /&gt;
  state = !state;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
If don't use the interrupt, push down the button, wait for a moment LED state will changed, otherwise use the interrupt LED state changes immediately.&lt;br /&gt;
&lt;br /&gt;
==Interrupt grammar==&lt;br /&gt;
*Grammar：&lt;br /&gt;
**attachInterrupt(interrupt, function, mode)&lt;br /&gt;
*Parameter：&lt;br /&gt;
**interrupt：interrput pin number &lt;br /&gt;
**function：when interrup happens, this function will be invoked to replace the running program. No parameter and no need return value for this function. It always called as Interrupt service routine(ISR).&lt;br /&gt;
**mode：Define when the interrupt happened, has four contstants values：&lt;br /&gt;
***LOW： When the pin is low electricity at ordinary times, raise the interrupt&lt;br /&gt;
***CHANGE： When the pin signal changed, raise the interrupt&lt;br /&gt;
***RISING ：When the pin changed from low level to high level at ordinary times, raise the interrupt&lt;br /&gt;
***FALLING ：When the pin changed from high level to low level at ordinary times, raise the interrupt&lt;br /&gt;
===Redistribute the interrupt===&lt;br /&gt;
Interrupt setting can be changed by function attachInterrupt() at any time. If use function attachInterrupt() to redistribute，previously assigned interrupt will be removed from the corresponding pin.&lt;br /&gt;
===Disable\enable interrupt===&lt;br /&gt;
microduino can ignore all interrupt. If you don't want to handle the interrupt in special code segment, you can use the noInterrupts() to disable interrupt. After this code segment, you can use interrupts() to enable the interrupt.&lt;br /&gt;
&lt;br /&gt;
===Delete the interrupt=== &lt;br /&gt;
You also can delete the interrupt by detachInterrupt(interrupt_number) in terminical. &lt;br /&gt;
==Note==&lt;br /&gt;
When the interrupt function occurs, delya () and millis () values will not continue to change.When an interrupt occurs, the serial port receives the data may be lost.You should declare a variable to store variable when not interrupted.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Jasonsheng</name></author>	</entry>

	</feed>