Home > other >  The use of the while (1)
The use of the while (1)

Time:09-26

The main ()
{
While (1)
{
Timer0Init ();
}
}

And
The main ()
{

Timer0Init ();
While (1);
}


What is the difference between the two, please?

CodePudding user response:

First, constantly perform Timer0Init () function,
Second, in performing a Timer0Init (), the program execution while (1) infinite loop,

CodePudding user response:

First, constantly perform Timer0Init () function,
Second, in performing a Timer0Init (), the program execution while (1) infinite loop,

CodePudding user response:

refer to the second floor Vast_August response:
first, constantly perform Timer0Init () function,
Second, in performing a Timer0Init (), the program execution while (1) infinite loop,

That don't directly behind a circular what's the difference?
The main
{

Timer0Init ();
}

CodePudding user response:

reference weixin_45837789 reply: 3/f
Quote: refer to the second floor Vast_August response:
first, constantly perform Timer0Init () function,
Second, in performing a Timer0Init (), the program execution while (1) infinite loop,

That don't directly behind a circular what's the difference?
The main
{

Timer0Init ();
}

If you don't have the while (1);
For example, you are there in this project, if there is no "while (1);" Finish this sentence, the program execution the main function the last sentence is over, you interrupt never response again, but if there is "the while (1);" This sentence, the program has been carry out this sentence, if the interrupt request, still go to the interrupt service function,

CodePudding user response:

Vast_August
reference 4 floor response:
Quote: refer to the third floor weixin_45837789 response:
Quote: refer to the second floor Vast_August response:
first, constantly perform Timer0Init () function,
Second, in performing a Timer0Init (), the program execution while (1) infinite loop,

That don't directly behind a circular what's the difference?
The main
{

Timer0Init ();
}

If you don't have the while (1);
For example, you are there in this project, if there is no "while (1);" Finish this sentence, the program execution the main function the last sentence is over, you interrupt never response again, but if there is "the while (1);" This sentence, the program has been carry out this sentence, if there is an interrupt request, still go to the interrupt service function,

Understand, thank you, not to say that the single chip microcomputer as long as the electricity has been constantly will run? How behind no death cycle will be over

CodePudding user response:

Finally performed will not end, the CPU executes code behind an address as the machine code, where the address is not the program will enter CPU fault interrupt with instructions,
  • Related