Interrupt Structure of ATmega328

for (int n=0; n<=4; n++)

{
       digitalWrite(4, HIGH); //L32:
       delay(1000); //L33:
       digitalWrite(4, LOW); //L34:
       delay(1000); //L35;
   }

We know only one ISR can run at a time and since delay() function requires interrupts to work, will it work under an ISR?

The code doesn't even compile, so I'm not sure why it was posted.

AWOL:
The code doesn't even compile, so I'm not sure why it was posted.

Sir,

This is Education and Teaching Section. I have to deal with tens of pupils who are individually using Arduino UNO Kits for their course works. The pupils desire that I prepare and post the class lectures in the Education and Teaching Section of the Forum so that they can read it online and down load it.

It may not be possible for all the time to test my all propositions and codes. I admit my all mistakes which are, to the best level of my sincerity, unintentional. However, if my endeavors are appearing as creating more problems for the pupils rather than offering them the benefits they are enjoying now I would certainly refrain myself from exercising these unnecessary efforts.

Thanks,

GolamMostafa:
The pupils desire that I prepare and post the class lectures in the Education and Teaching Section of the Forum so that they can read it online and down load it.

In that case shouldn't you be hosting it on your own web site?

dannable:
In that case shouldn't you be hosting it on your own web site?

The decision should come from the Moderator.

GolamMostafa:
The pupils desire that I prepare and post the class lectures in the Education and Teaching Section of the Forum so that they can read it online and down load it.

And the pupils are happy to correct the code themselves, after downloading it?
Do you pre-warn them that it won't compile, and then won't work, even when the syntactic errors are fixed?
Is this part of the teaching process?

Doesn't your faculty have its own website?

urmil123:
We know only one ISR can run at a time and since delay() function requires interrupts to work, will it work under an ISR?

Let us see what happens when an IRQ arrives at the INT0-pin and before the ISR is executed:
(1) The MCU disables the Global Interrupt Enable Bit (I-bit of SREG is made 0)
(2) The ISR contains a program that blinks a LED for 5 times. This blinking task has used the built-in delay() function of the Arduino.
(3) The delay() function works on interrupts; but the interrupt is disabled. So, we have to re-enable it just after arriving at the ISR, and it is done by executing the instruction interrupts();.
(4) Please down load and open the program P645.ino, and you see that the instruction interrupts(); has already been executed just after arriving at the ISR.
(5) Therefore, the ISR should work normally. The inclusion of reti(); helped in my case for the MCU to make a normal return to the MLP though it should not be required.

BTW: To the best of my knowledge, I compiled and tested the program P645.ino before posting it. I have attached the original file and also has typed it in the code box. It is a good practice that we use the attached file rather than the typed file which might have typographical errors.

Have you compiled the program? Have you seen any errors?

Doesn't your faculty have its own website?

Rather than cross questioning and answering, please pass the verdict according to the rules of the Forum. Enough is enough!

Void setup()
{

I don't need to present that to the compiler to know that it will be spat out.

GolamMostafa:
Rather than cross questioning and answering, please pass the verdict according to the rules of the Forum. Enough is enough!

I don't want you to waste your time and effort, but also I don't want anyone posting authoritative-looking topics that are misleading.

I don't have the time to check all posts on the forum, nor do the other mods, but ones with blatant (to me) mistakes, or topics reported to the moderators will obviously be pointed out.

And the pupils are happy to correct the code themselves, after downloading it?
Ans: Ask the pupils.

Do you pre-warn them that it won't compile, and then won't work, even when the syntactic errors are fixed?
Ans: The question should come from the pupils/Evaluation Committee.

Is this part of the teaching process?
Ans: The question again should come from the Evaluation Committe.

Doesn't your faculty have its own website?
Ans: No need! The faculty and the pupils have paid hundreds of dollars for the Arduino Learning Kits. It is their rights and not the privileges to enjoy all the available resources of the Forum subject to the compliance of the rules of the Forum.

AWOL:

Void setup()

{



I don't need to present that to the compiler to know that it will be spat out.

That's why the French people say:

"The Rules are for the Monkeys and not for the Human Beings who constantly apply their instincts and judgments."

AWOL:
I don't want you to waste your time and effort, but also I don't want anyone posting authoritative-looking topics that are misleading.

I don't have the time to check all posts on the forum, nor do the other mods, but ones with blatant (to me) mistakes, or topics reported to the moderators will obviously be pointed out.

People are punished for the crimes and not for the mistakes! Crimes are committed intentionally; the mistakes are the parts of human nature!

By correcting mistakes one can reach to a very high level of perfection, but not the culprits!

GolamMostafa:
By correcting mistakes one can reach to a very high level of perfection, but not the culprits!

Excellent! I am glad to know that your next action will be correcting your mistakes so you can reach to a very high level of perfection!

A great place to start is that "Void".

GolamMostafa:
That's why the French people say:

"The Rules are for the Monkeys and not for the Human Beings who constantly apply their instincts and judgments."

I've spent a significant amount of my life in many different parts of France, and have many French friends and acquaintances, and I have yet to hear one of them utter that phrase.

I simply apply my reading skills, but then, I'm just a naked ape. The compiler is even dumber.

AWOL:
I've spent a significant amount of my life in many different parts of France, and have many French friends and acquaintances, and I have yet to hear one of them utter that phrase.

Myself, too, have spent a major part (more than 15 years) of my early car rear with second largest Oil Company of the world where I encountered a mixed culture of British, French, American, and others minority including myself. We were working mainly in the oil fields located in desert, off-shore, and on-shore as well. In this multi-cultural working environment, I came to be familiar with two spontaneous foreign expressions : "Fu..... in the hell" and "Rules for the Monkeys....; the Americans were a bit shy."

The first was fine, which I even enjoyed in 1979 in Rugby, UK; but, the second was really targeted at me by my Station Manager Mr. Patrick Philip , a French man.

It was the time of 1985 in an oil field in the Far East where I had been logging the 3000-ft deep oil-well data for the last 20+ hours using PDP-11, Magnetic Tape, and a Tektronics Monitor; the client was the Shell Oil Company. As I was nearing the end of the job, I did not give much attention on the real-time quality control of the logging data of the last 100-ft. After finishing the logging job, I was doing some house-keeping works in the doghouse.

In the mean time, my Station Manager arrived as a part of his field visit and played back few selected portions of the logged data before handing over it to the client. Having had a look at the last 100-ft logging data (it was a noisy record due high logging speed; the crews were hungry, sleepy, ...), he shouted at me: Mo.....! "I placed a well trained man like you in front of a Computer to control that the machine, you, and crew together would be recording technically valid data. You left everything to the Computer believing that the machine would be doing good job for you. And then he commented, 'Rules are for the Monkeys and not for the human beings....'. Never mind, this is the way how we learn things!"

It is about 30 years! Perhaps, I remained the same. My keyboard was typing capital V (in Void) instead of lower-case v, and I was made responsible for it because it was my duty to check what actually had appeared on the monitor before it was released to the pupils (the Forum).

Thanks for giving time to hear my story!

Have a good night!

[quote author=Coding Badly link=msg=3377479 date=1502806180]
Excellent! I am glad to know that your next action will be correcting your mistakes so you can reach to a very high level of perfection![/quote]

Mistakes can only be corrected if someone generously points to it! Where shall we get such a generous man? Everybody is perfect here except me! A perfect man always sees everything in a perfect way. So, there will be none, at least as a part of argument, to notice my mistakes; there will be no chance for me even to become a good man; never mind about perfection!!

This is Education and Teaching Section. I have to deal with tens of pupils who are individually using Arduino UNO Kits for their course works. The pupils desire that I prepare and post the class lectures in the Education and Teaching Section of the Forum so that they can read it online and down load it.

You are trying to teach beginning Arduino students about external interrupts. I think that re-enabling interrupts within the isr so as to use delay() is not a good approach. I think you would be far better to hammer home the message to keep the isr short and fast and don't call functions which rely on interrupts being enabled.

Why not set a flag and execute the function in loop() with blink without delay. Teaching the use of flag setting in an ISR is a valuable lesson.

You may believe differently, but when you see all the broken ISR's posted on this forum, and posters asking for help it leads me to be skeptical of your approach.

cattledog:
[...] Why not set a flag and execute the function in loop() with blink without delay. Teaching the use of flag setting in an ISR is a valuable lesson.

You may believe differently, but when you see all the broken ISR's posted on this forum, and posters asking for help it leads me to be skeptical of your approach.

Thanks for the valuable comment. I have noted it down.

Yes! Blink without delay would be an excellent approach to keep the ISR short.

//----------------------------------------------------------------------------------------------------------
Let me share with the readers my experiences of teaching interrupt (or any other) concepts with the senior level graduate students of Electrical Engineering:

(1) As a faculty, one has to prepare a working experiment that gives a visible result, and the experiment should be reproduceable. The faculty makes the experiment in accordance with his level of understanding of the subject matter and the practical experience.

(2) The faculty must prepare the step-by-step procedures of the experiment so that each and every student can reproduce the result just by following the steps.

(3) The faculty goes into interactive section with the pupils to review the theoretical and the setup aspects of the experiments.

(4) The pupils are again asked to repeat the experiment and justify the necessity of the steps as have been laid down in the experiment.

(5) The students are now allowed to search in the web or among themselves to look for alternative or better ways of doing the experiment.

(6 In 3x50 minutes class, the faculty and the students (a few of good quality) have time to play around with the experiment. The advantage is that the students have their own (purchased) Arduino UNO Learning Kits.

(7) My understanding is: These are Electrical Engineering level students. They don't have wide exposure to programming arena like the CSE students. Very often, we need to go to assembly level to make them understand what is going on at the register/memory level of the MCU.

//-----------------------------------------------------------------------------------------------------------

GolamMostafa:
And the pupils are happy to correct the code themselves, after downloading it?
Ans: Ask the pupils.

I don't KNOW any of YOUR students.

Do you pre-warn them that it won't compile, and then won't work, even when the syntactic errors are fixed?
Ans: The question should come from the pupils/Evaluation Committee.

No, the question came from me.

Is this part of the teaching process?
Ans: The question again should come from the Evaluation Committe.

Again, you're not following - the question came from me (also sp. "committee")

Doesn't your faculty have its own website?
Ans: No need! The faculty and the pupils have paid hundreds of dollars for the Arduino Learning Kits. It is their rights and not the privileges to enjoy all the available resources of the Forum subject to the compliance of the rules of the Forum.

Over years, I've spent many tens of thousands of pounds at Shell and Esso, but they don't allow me to flog my goods at their outlets. Why is that? Aren't they required to grant me some sort of squatters' rights at their filling stations?