??? 05/15/04 01:24 Read: times |
#70381 - RE: 8051 program repeat itself? Responding to: ???'s previous message |
Andy Wong said:
I thought it will execute the commands and stay idle No processor of any sort ever does anything unless you tell it to. On a PC (or Mac, or UNIX, or VAX, or...) you have an operating system running. When you run a program, the operating system loads it, runs it, and it then returns to the operating system when it's done. The operating system is constantly running so long as the PC is on - always checking for commands, system events, etc - it never stops until you turn the power off. On your 8051, you have no operating system. So, when your main() finishes, it just carries on executing the empty bytes in your ROM in sequence. Eventually, it will reach the end of the ROM and "wrap around" to address zero - which is where it all started! Thus your code keeps repeating indefinitely! If you want your processor to go idle at the end of main(), you will have to insert the appropriate instructions to put your processor into its idle mode - see the Data Sheet. A common way to "catch" a program at the end of main() is to use an infinite loop; eg, for( ;; ); More usually, the entire main() of an embedded system is one big infinite loop - think about it: when you switch a piece of equipment on, you expect it to just keep performing its functions until you turn it off. You don't expect to reboot your telly at the end of each programme! |
Topic | Author | Date |
8051 program repeat itself? | 01/01/70 00:00 | |
RE: 8051 program repeat itself? | 01/01/70 00:00 | |
RE: 8051 program repeat itself? | 01/01/70 00:00 | |
RE: 8051 program repeat itself? | 01/01/70 00:00 | |
begin with the basics | 01/01/70 00:00 | |
RE: begin with the basics | 01/01/70 00:00 | |
RE: begin with the basics![]() | 01/01/70 00:00 |