Go Down

Topic: Ch-8 Interrupt Structure  (Read 3315 times) previous topic - next topic

GolamMostafa

Jun 20, 2020, 06:53 pm Last Edit: Jun 24, 2020, 07:24 pm by GolamMostafa
8.1  Introduction
(1)  Interrupting the MCU means telling it to suspend what it has been doing. For example: In Fig-8.1, the MCU is continuously blinking L (built-in LED of UNO) at 1-sec interval. "Blinking L" is a job that is known as "Main Line Program (MLP)".

Figure-8.1: Demonstration of the interrupt process of ATmega328P MCU

(2)  Now, ask the MCU by pushing the external switch K1 to suspend the MLP of Step-1 and then blink LED1 (Fig-8.1) only for 3 times at 2-sec interval and then resume the MLP. "Blinking LED1" is a "side job" which is known as "Interrupt Sub Service Routine (ISR)". The symbolic name of the ISR in Fig-8.1 is: ISRINT0 (ISR due to interrupt at INT0-pin). Practically, the ISR routine should be as short as possible. Why should the ISR routine be short?    

(3)  The "external switch K1" is called an "Interrupting Device".

(4)  When K1 is pressed down, the signal level of INT0-pin (Fig-1) of the MCU changes from HIGH to LOW; as a result, the MCU gets interrupted. The signal at the INT0-pin, which interrupts the MCU is called "Interrupting Signal". The symbolic name of the interrupting signal in Fig-8.1 is: IRQ0 (interrupt request 0). The HIGH level at DPin-2 (Fig-8.1) comes from 5V rail via "internal pull-up resistor Rip".

(5)  The value of the interrupting signal is also known as "Trigger Level". The options for trigger level are (Fig-8.2):
(a)  FALLING (falling edge FE),
(b)  LOW (active low AL), and
(c)  RISING (rising edge RE).


Figure-8.2: Interrupt trigger levels of ATmega328P MCU

Note:  (a)  At the presence of any event (LWO or FE or RE) at DPin-2, the INTF0 bit/flag of the MCU assumes HIGH state. This flag generates interrupt signal (IRQ) for the MCU provided SW1 (called local interrupt enable bit for INT0 interrupt) and SW2 (called global interrupt enable bit for all interrupts, Fig-8.8) are put into closed conditions (enabled states) in the setup() function. SW1 and SW2 together makes "something" what is called the "interrupt logic". More information on INTF0 flag could be found in Section-8.2 and datasheets.

(b)  SW1 and SW2 becomes closed means "interrupt logic" becomes enabled when this code: attachInterrupt(arg1, arg2, arg3); is executed in the setup() function.

(6)  In Fig-8.1, we observe that the ATmega328P of the UNO Board has two physical pins (Pin-4, 5) to receive interrupt signals from external sources. The symbolic names of these two pins ate: INT0 and INT1 which are connected with DPin-2 and 3 respectively.

(7)  After interruption, the MCU will suspend the MLP and then will jump to ISR routine; therefore, a code should be executed in the setup() function to establish a relation/connection between DPin-2 (IRQ0 comes to INT0-pin of MCU via this DPin-2) and ISRINT0 routine. The following is the code that makes the said relation/connection.
Code: [Select]
attachInterrupt(digitalPinToInterrupt(DPin), ISRName, TriggerLevel);
==> attachInterrupt(digitalPinToInterrupt(2), ISRINT0, LOW); //for INT0 interrupt

Note:  The above code also enables "interrupt logic (Fig-8.2)" so that the MCU is interrupted at the arrival of an interrupt signal. The "interrupt logic" is composed of:

(a)  "Local Interrupt Enable Bit" represented by SW1 in Fig-8.2. It must be in closed position so that the MCU can be interrupted by an interrupt signal.

(c)  "Global Interrupt Enable Bit" represented by SW2 in Fig-8.2, It must be in closed position so that the MCU can be interrupted by an interrupt signal.

(8)  Let us note down that the MCU deactivates/disables "global interrupt enable bit" (means opens SW2 of Fig-8.2) before going to ISR routine so that it is not further interrupted until the current side job (the ISR routine) is completed. Also note that the delay() function needs active state of "global interrupt enable bit" for its own functioning. Therefore, it will not be possible to execute delay() function in the ISR routine. Now, the blinking job of LED1 of the ISRINT0 routine has to be done in the loop() function as "global interrupt enable bit" remains enabled in the loop() function. How will loop() function know that there happened an interrupt event? This will be known to the loop() function by setting up a flag into true state in the ISR routine. The loop() function will test the flag and if found true, it will understand that interrupt had happened and then it will blink LED1 for  3 times at 2-sec interval using delay() function. For the codes, please see Section-9(f).

(৮)  ধরুন, আমার সাথে একজন ছাএ কথা বলতেছে। এই ছাএের সাথে আলাপ শেষ না হওয়া পর্যন্ত, আমি ২য় কোনো ছাএের সংগে আলাপ শুরু করবোনা; অর্থাৎ, ২য় ছাএের কাছ থেকে আসা ইনটারাপট (interrupt) আমার দ্বারা অগ্রাহ্য হবে। মাইক্রোকন্ট্রোলালের (MCU) ক্ষেএেও একই রকম ঘটনা ঘটে। মাইক্রোকন্ট্রোলার, ISR routine-এ প্রবেশ করার আগ মূহু্র্তে, "Interrupt Logic"-কে নিষ্ক্রিয় (disable) করে ফেলে। ISR routine-এ গিয়ে LED1 ৩-বার ২-সেকেন্ড পর পর বিলিংক (blink) করার কথা এবং এ কাজের জন্য delay() ফাংশন ব্যাবহার করবে। কিন্তু, এই  delay() ফাংশন কাজ করবে যদি "Interrupt Logic" সক্রিয় (enabled) থাকে। "Interrupt Logic" অলরেডি নিষ্ক্রিয় করা আছে; অতএব, ISR routine-এ LED1-কে বিলিংক করা যাবেনা। বিলিংকিং কাজটা loop() ফাংশনে নিষ্পন্ন করতে হবে; যেহেতু, loop() ফাংশনে "Interrupt Logic" সক্রিয় থাকে। তা হলে, প্রশ্ন উঠে--loop() ফাংশন জানবে কেমনে যে, ইনটারাপট ঘটনা ঘটেছিল?  loop() ফাংশনকে এই জানানটা দেওয়ার জন্য, ISR routine-এ একটা flag সেট করা হয়। মাইক্রোকন্ট্রোলার loop() ফাংশনে এই flag টেষ্ট করে এবং এর মান true পেলে বুঝে নেয় যে ইনটারাপট ঘটনা ঘটেছিল; আর, কেবল মাএ তখনই LED1 ৩-বার ২-সেকেন্ড পর পর বিলিংক করবে। কোডের (code) এর জন্য  Step-9(f) দেখুন।                  

(9)  Let us create the sketch to accomplish the interrupt process for INT0 interrupt of Fig-8.1.
(a)  Begin with two blank functions -- setup() function and loop() function.
(b)  Place the following codes in the setup() function to accomplish the tasks (known as initialization) briefly described in the comment field.
Code: [Select]
Serial,begin(9600);  //to connect Serial Monitor
pinMode(13, OUTPUT);      //to drive L (built-in LED of UNO
digitalWrite(13, LOW);      //L is initially OFF
//---------------------------------------------------------------
pinMode(8, OUTPUT);      //to drive LED1 of ISRINT0 routine
digitalWrite(8, LOW);      //LED1 is initially OFF
  
//---------------------------------------------------------------
pinMode(2, INPUT_PULLUP);  //internal pull-up is connected with DPin-2/INT0-pin
attachInterrupt(digitalPinToInterrupt(2), ISRINT0, LOW);//make connection between INT0 and ISRINT0

 
(c)  Place the following codes in the loop() function to blink L continuously at 1-sec interval.
Code: [Select]
void loop()
{
    digitalWrite(13, HIGH);
    delay(1000);
    digitalWrite(13, LOW);
    delay(1000);
}

(d)  Place the following ISRINT0 routine at the end of the loop() function.
Code: [Select]
void ISRINT0()
{
   flag = true;   //flag will allow to blink LED1 for 3 times at 2-sec interval using delay() function
}

(e)  Place the following declarations in the global area of the sketch.
Code: [Select]
byte counter = 3;    //LED1 of ISRINT0 routine be executed for 3 times via the loop() function.
volatile bool flag = false;

(f)  Re-write loop() function as follows so that the LED1 could be blinked in the loop() function at 2-sec interval using delay() function when an interrupt signal arrives at the INT0-pin of the MCU.
Code: [Select]
void loop()
{
  if (flag == false)    //interrupt has not occurred; keep blinking L
  {
    digitalWrite(13, HIGH);
    delay(1000);
    digitalWrite(13, LOW);
    delay(1000);
  }
  else    //interrupt has arrived at INT0-pin via DPin-2; blink LED1 for 3 times
  {
    do
    {
      //-------------------
      digitalWrite(8, HIGH);
      delay(2000);
      digitalWrite(8, LOW);
      delay(2000);
      //-------------------
      counter--;
    }
    while (counter != 0);
    flag = false;
    counter = 3;
  }
}


...see next post.

GolamMostafa

#1
Jun 20, 2020, 06:55 pm Last Edit: Jun 24, 2020, 03:48 pm by GolamMostafa
8.2  Hardware Details of Interrupt Logic of ATmega328P MCU

Figure-8.3: Details of interrupt logic

(1)  Hardware De-bouncing Circuit (M1):  K1 (the interrupting device) is a mechanical switch. When it is pressed down, it makes hundreds of bouncing like a "bouncing ball" before it makes the final sitting in the closed position; as a result, there are productions of many many interrupt request signals for the MCU. In order to prevent the MCU from responding to all these extra triggers, there will be a need of a "de-bouncing mechanism" to suppress these extra triggering pulses. The de-bouncing of K1 could be done using hardware circuit like M1 of Fig-8.3 or "using software routine".  

(2)  Setting up Trigger Level
(a)  In Fig-8.3, it is observed that SW3 selects the desired trigger level. SW3 changes its position according to the value of the 3rd argument of the attachInterrupt() (8.1.7) instruction - a high level function. Here, we will see (with reference to Fig-8.3) how the same action could be carried out using register level instructions. This example will also establish that all high level codes/functions/methods are eventually converted down to register level codes and then to machine level (binary codes) codes before being stored into the flash/code memory of the MCU for execution.

(b)  Fig-8.3 says that the ISC00 and ISC10 (Interrupt Sense Control) bits of the EICRA Register (External Interrupt Control Register A; consult datasheets for full description) controls the position of SW3 to set trigger level.  To set "Trigger Level" at LOW state, we may execute the following codes where [0:0] ==> [ISC01:ISC00].
(i)
Code: [Select]
bitClear(EICRA, ISC00);  //bitClear(RegisterName, BitName);
bitClear(EICRA, ISC01);

Or
(ii)
Code: [Select]
bitWrite(EICRA, ISC00, LOW); //bitWrite(RegisterName, BitName, BitValue)
bitWrite(EICRA, ISC01, LOW);

Or
(iii)
Code: [Select]
bitWrite(EICRA, 0, 0); //bitWrite(RegisterName, BitPosition, BitValue)
bitWrite(EICRA, 1, 0);

Or
(iv)
Code: [Select]
attachInterrupt(digitalPinToInterrupt(2), ISRINT0, LOW); //last arg from left is trigger level
Question:  Which one of the above four examples is confusing and unfriendly?

(3)  Role of INTF0 Flag
Whenever an event such as LOW or FE or RE of a signal appears on DPin-2/INT0-pin of the MCU, the INTF0 flag/bit (Flag for External Interrupt on INT0-pin) of EIFR Register (External Interrupt Flag Register) assumes HIGH state. This HIGH state will immediately interrupt the MCU should the  SW1 (local interrupt enable bit) and SW2 (global interrupt enable bit) switches are at closed conditions.

The logic value of INTF0 flag is reflected/passed to the user via Bit-0 (the INTF0 bit) of the EIFR Register (External Interrupt Flag Register) of the MCU. If SW1 and  SW2 are kept opened, the user program can still monitor the value of INTF0 flag to check if any event has occurred at DPin-2/INT0-pin of the MCU and then take action as necessary.    

(4)  Closing Mechanism of SW1 (the Local Interrupt Enable Bit for INT0 interrupt)
INT0 bit of EIMSK Register (External Interrupt Mask Register) controls the opening/closing states of SW1. Putting HIGH (1) at the said bit closes SW1; whereas, putting LOW (0) opens the switch. Now, the following codes could be executed to close SW1.
(i)
Code: [Select]
bitSet(EIMSK, INT0);
Or
(ii)
Code: [Select]
bitWrite(EIMSK, INT0, HIGH);  //bitWrite(RegisterName, BitName, BitValue)
Or
(iii)
Code: [Select]
bitWrite(EIMSK, 0, 1);  //bitWrite(RegisterName, BitPosition, BitValue)
Or
(iv)
Code: [Select]
attachInterrupt(digitalPinToInterrupt(2), ISRINT0, LOW);
The above code (no. iv) does not explicitly contains the codes to close SW1 and SW2; but, the codes are embedded within the attachInterrupt() function.

(5)  Closing Mechanism of SW2 (the Global Interrupt Enable Bit for all interrupts except RESET)
It is left as an exercise for the readers.

...see next post.

GolamMostafa

#2
Jun 20, 2020, 06:55 pm Last Edit: Jun 24, 2020, 04:40 pm by GolamMostafa
8.3  Questions and Answers
1.  What do you mean by "interrupting the microcontroller"?
It means telling the MCU to suspend what it has been doing and then turn to the side job (the ISR routine); finish the ISR routine and then resume the MLP.

2.  State the conditions that must be satisfied before interrupting MCU over INT0-pin in Fig-8.1?
Ans:  (1)  The interrupting device (K1 of Fig-8.1) must be installed by the user,
(2)  MLP Program must be written, tested and kept in flash/code memory.
(3)  ISRINT0 Routine must be written, tested and kept in flash/code memory,
(4)  The trigger level should be set (Fig-8.2) using code in the setup() function,
(5)  Relation between DPin-2 and ISRINT0 routine must be established using code in the setup() function.
(6)  "Local interrupt enable bit" (Fig-8.2) must be made active (SW1 is closed) using code in the setup() function.
(7)  "Global interrupt enable bit" (Fig-8.2) must be made active (SW2 is closed) using code in the setup() function.
(8)  Execute the MLP Program, and
(9)  Just press and release the the interrupting device.

3.  What are the events that happen when the MCU is interrupted?
Ans:  (1)  Current job (the MLP) is suspended.
(2)  The MCU will enter into the ISR routine.
(After finishing the ISR routine, the MCU will resume the MLP execution from the label/address at which the MLP was left behind. This label/address is known as "return label/address" (Fig-8.4). The MCU saves this return label/address onto stack space (block of RAM memory, Fig-8.6) before entering into ISR routine.)

(3)  "Global interrupt enable bit" (Fig-8.2) is automatically deactivated/disabled (SW2 gets opened) so that the MCU is not interrupted again until the current ISR is completed.

(4)  The MCU finishes the ISR.
(5)  MCU returns to MLP and begins program execution from the "return label/address". During return time, the "global interrupt enable bit" is re-enabled (SW2 is closed) so that the MCU can be again interrupted.

4.  The events that are happening in Q3 in response to an interrupt signal can be described by the "Interrupt Flow Diagram" of Fig-8.4. Read the diagram and the description that follow.

Figure-8.4: Interrupt Flow Diagram for INT0 interrupt

Description: The MCU starts the execution of MLP at time t0 at label ML1. At time t1 of label ML2, interrupt signal arrives at INT0-pin. If interrupt would not happen, the MCU would execute code/instruction at label ML3. Because interrupt has arrived, the MCU finishes code/instruction of label ML2. After that the MCU saves the return label/address (ML3) onto stack (a memory block in RAM, Fig-8.6), disables "global interrupt enable bit" and then enters into ISRINT0 routine at time t2.. At time t3, the execution of ISRINT0 is finished; the MCU re-enables the "global interrupt enable bit" and retrieves the "return label (ML3)" from stack and then resumes MLP at time t4 at label ML3.

5.  What is the purpose of internal pull-up resistor of Fig-8.1 in relation with INT0 interrupt?

6.  K1 of Fig-8.1 is a mechanical switch. Do you think that the switch will make hundreds of bounces like a bouncing ball before making the final contact? If so, what arrangement should we make to kill theses bouncing to prevent the MCU from being interrupted again and again?
Ans:  Section-8.2(1).

7.  Look at Fig-8.1 and tell how many sources of external interrupt signals are there for the MCU?

8.  We have seen in Section-8.1(7) that attachInterrupt() function enables "interrupt logic" (both local interrupt enable bit and global interrupt enable bit); as a result, the MCU is interrupted in response to an interrupt signal. Is  there any instruction to disable the "interrupt logic" or "global interrupt enable bit" so that the MCU will not respond to any interrupt request? (Check with Q22 and find that the MCU can receive 26 interrupt signal of which RESET interrupt is special which can not/should not be disabled.)

Ans:  One of the following instructions could be executed to disable "interrupt logic"/"global interrupt enable bit".
Code: [Select]
detachInterrupt();  //breaks relation between DPin-2, ISRINT0; disables "interrupt logic".
noInterrupts();               //disables "global interrupt enable bit".
cli();                              //same as above == noInterrupts()
bitClear(SREG, I); //same as cli(); I for interrupt flag; it is bit-7 of SREG (Status Reg.) of MCU;


9.  What are the counter part instructions of Q7?
Code: [Select]
attachInterrupt(arg1, arg2, arg3);  
interrupts();    //enables "global interrupt logic"
sei();              //same as interrupts()
bitSet(SREG, I);    //same as interrupts()


10.  Look at the Table of Q22 and observe that there are in total 26 sources of interrupt signals for the MCU. When the "global interrupt enable bit" is disabled, the MCU will not respond to any of the interrupt requests. However, the user might want that the MCU would respond to only INT0 interrupt and all other interrupts would remain OFF (disabled). How can it be achieved.
Ans:  There are individual enable/disable switches (called local interrupt enable switch/bit) for each of the interrupts. There is also a "global interrupt enable bit/switch" (Fig-8.5) which enables/disables all interrupts. So, all the "local interrupt enable bits" would be set at "disable states" (individual switches are opened) except for the INT0 interrupt (designated as Intv-2 in Fig-8.5 and as SW1 in Fig-8.2) or for the interrupt of interest. The "global interrupt enable bit/switch" will remain in closed condition. The scenario is explained with the help of the following diagram.

Figure-8.5: Roles of local/global interrupt enable bit

Questions:  (a) What does Intv-2 stand for?
Ans: Interrupt vector No. 2. (see Q15(c)).
(b)  Why is the RESET interrupt not included in Fig-8.5?

11.  List the names of the hardware/software items that are related with INT0 process of Fig-8.1.
(1)  Interrupting device,
(2)  Enabling internal pull-up resistor,
(3)  Setting up trigger level of the IRQ0 signal,
(4)  Codes for MLP Program,
(5)  Codes for the setup() function,
(6)  Codes for the loop() function, and
(7)  Codes for the ISINT0 routine,

12.  Give an example of a method that should not be not be executed in the ISR routine.

13.  Write code to establish connection between ISRINT1 and DPin-3 for INT1 interrupt process.

14.  Write codes for the loop() function of the INT1 process so that the ISRINT1 will show this message on the Serial Monitor: "Interrupt happened at INT1-pin" when an IRQ1 signal arrives at INT1-pin of Fig-8.1.

15.  Define "program Address", "Interrupt Vector", and "Vector No." -- terms that are found in Q22.
(a)  Program Address:  When interrupt happens, the MCU goes to the ISR routine which resides somewhere in the flash/code memory of the MCU. The code memory has many word-organized locations (Fig-8.6); where, every word-location has an address. Program Address is the beginning address of the flash that contains codes of the ISR routine. When INT0 interrupt happens in ATmega328P MCU, the MCU always looks for the ISRINT0 routine at address 0x0002 (fixed address, Fig-8.8) ; this is the Program Address for INTO interrupt. Because there is not much locations starting from 0x0002 to hold the codes of the ISRINT0, the user makes a jump to a larger area (user program area in Fig-8.6) of the flash.

Figure-8.6: Memory space organization of ATmega328P MCU

(b)  Interrupt vector:  When INT0 interrupt happens, the MCU is always directed to jump to a known location 0x0002 to begin with the execution of ISR routine. That means that the MCU is vectoring (going to a particular direction/location) at location 0x0002 due to INT0 interrupt -- hence the terminology of "Interrupt vector".  

(c)  Vector No.:  In the Table of Q22, there are 26 Program Addresses for 26 interrupts. The interrupts are given "Serial No." based on their address value. Thus, "Vector No. 2" is given to INT0 interrupt; "Vector No. 3" for INT1 interrupt and so on.    

... see next post.

GolamMostafa

#3
Jun 21, 2020, 08:09 am Last Edit: Jun 24, 2020, 07:23 pm by GolamMostafa
16.  Assume that INT0 and INT1 interrupts have happened at the same time in Fig-8.1. Which interrupt would be served first by the MCU?
Ans:  In ATmega328P architecture, the interrupt with lower valued program address (lower interrupt vector no.) has the higher priority. Table of Q22 says that 0x0002 is the Program Address for INT0 interrupt and 0x0004 is the program Address for INT1 interrupt; so, INT0 will be executed first and then the INT1 interrupt. Also, note that INT0 has the "Vector No. 2" and INT1 has the "Vector No. 3".    

17.  Assume that the ISRINT1 is in progress. In the meantime, INT0 has happened. What is the result?
Ans:  INT0 interrupt has the higher priority over INT1 interrupt; so, ISRINT1 would be suspended and ISRINT0 would come into action; but, "interrupt logic" is disabled; so, ISRINT1 would remain in progress.

In case, the user enables the "global interrupt enable bit" after arriving at the ISRINT1 and bu executing interrupts() code, then interrupt with higher priority will come into action and once it is completed, the suspended ISRINT1 routine will resume. This is something known as nested interrupt (Fig-8.7).

Figure-8.7: Nested interrupts

18.  The command delay(); is a function and the command Serial.print(); is a method. What is the difference between function and method in the context of C++ programming when both of them do some works?

19.  Referring to Section-8.1.9(f) for the codes of loop() function, you are asked to re-write the codes using for() loop instead of do-while structure. Is there any gain of using do-while structure with global variable (the counter) instead of using for() structure with local variable?

20.  When using attchInterrupt() function, we use the following declaration for the ISRINT0 routine:
Code: [Select]
void ISRINT0()
{
    //code here
}

If not using attchInterrupt(), what kind of declaration we would be using for ISRINT0 routine?
Ans:  The declaration is made as follows using few keywords:
Code: [Select]
ISR(INT0_vect)
{
   //code here
}

21.  Referring to Fig-8.3, write code to keep checking that the INTF0 bit/flag has assumed HIGH state.

22.  The following Table (Fig-8.8) describes all possible sources of interrupts for the ATmega328P MCU.

Figure-8.8:

TheMemberFormerlyKnownAsAWOL

ISR == Interrupt Service Routine
Please don't PM technical questions - post them on the forum, then everyone benefits/suffers equally

GolamMostafa

#5
Jun 21, 2020, 09:04 pm Last Edit: Jun 23, 2020, 07:05 am by GolamMostafa
"Honored" and the post is updated/corrected.

TheMemberFormerlyKnownAsAWOL

Code: [Select]
byte counter = 3;    //LED1 of ISRINT0 routine be executed for 3 times via the loop() function.
...

void loop()
{
...
  else    //interrupt has arrived at INT0-pin via DPin-2; blink LED1 for 3 times
  {
    do
    {
      //-------------------
      digitalWrite(8, HIGH);
      delay(2000);
      digitalWrite(8, LOW);
      delay(2000);
      //-------------------
      counter--;
    }
    while (counter != 0);
    flag = false;
    counter = 3;
  }
}
Sometimes, when writing code in a commercial environment, where there is a chance of theft or plagiarism, there is a good argument for writing elements of the code in a way that is not the most logical, or that deliberately does not promote good programming practice.

In an educational example, I can't see that such constructs are relevant or appropriate.
Please don't PM technical questions - post them on the forum, then everyone benefits/suffers equally

GolamMostafa

#7
Jun 22, 2020, 05:24 pm Last Edit: Jun 22, 2020, 05:29 pm by GolamMostafa
Probably, I have not properly understood your point.

In my proposition, I have said that the MCU will blink LED1 in the ISRINT0 for 3 times at 2-sec interval. I have assumed that my novice readers (including me) know only about delay() function that inserts time delay. As "interrupt logic" will remain disabled in the ISRINTO routine, delay() function could not be executed in the said ISR routine because delay() function itself needs an enabled "interrupt logic' for its operation. Therefore, I must find a way to demonstrate that the ISRINT0 still blinks LED1 at 2-sec interval using delay() function; it is done under the umbrella of loop() function where if-else structure has been used to select either the MLP or the ISRINT0 depending on the value of flag which is set to true by the ISRINT0 routine in response to interrupt.      

TheMemberFormerlyKnownAsAWOL

Why use a do..while, with a global variable, when a for-loop with a local variable will do just as well?

Unless you're protecting IP, and on the lookout for plagiarism.
Please don't PM technical questions - post them on the forum, then everyone benefits/suffers equally

GolamMostafa

#9
Jun 22, 2020, 05:56 pm Last Edit: Jun 23, 2020, 07:02 am by GolamMostafa
Now, I have got your point; let me think over it. I wrote the codes just for a solution, and I had no sense at all about safeguarding the "intellectual property" or preventing the codes from "being copied". I will accommodate your observation in the Questions and Answers Section of my thread.

TheMemberFormerlyKnownAsAWOL

It's not about copy-prevention, just making it obvious that it has been copied.
Please don't PM technical questions - post them on the forum, then everyone benefits/suffers equally

Koepel

#11
Aug 25, 2020, 09:19 am Last Edit: Aug 25, 2020, 09:21 am by Koepel
I am confused by this, it is between ( 8 ) and ( 9 ). It is also in the pdf-document "Ch-8OnlineLec-1.pdf".


GolamMostafa

Fortunately, Google translates English or any other Language into my mother tongue - Bangla; unfortunately, the Google does not do the reverse. It is (what you see/referred) is a Bangla version of an English paragraph and is intended for my Bangla speaking pupils.

Go Up