To know the working principle of a microcontroller we should know difference between von neumann architecture and harvard architecture of microcontroller. Depending upon the data fetching and programming code fetching technique, we can divide the Architecture of microcontroller in two types
1) Von-Neumann architecture
2) Harvard Architecture
Now to discuss on Difference between von neumann architecture and harvard architecture of microcontroller we should know that the ROM is use for storing the programming instruction and RAM is use for storing the data. Now we use bus for interfacing the ROM and RAM with CPU. In early days only single bus are used for interfacing ROM and RAM that means using the same bus data and as well as instruction code being fetch. This type of architecture is called Von-Neumann architecture. In bellow figure you can see how it interfaces with RAM and ROM.
Because of using same bus for interfacing RAM and ROM, the execution and processing become very slow. For fetching data or code it has to wait until one is finished.
To overcome the problem or we can say speed up the execution and processing time of microcontroller, a new architecture introduced named Harvard Architecture. In Harvard Architecture two different buses are uses for fetching the ROM and RAM that means the ROM and RAM are two different memories. In bellow in bellow figure you can see how it interfaces with RAM and ROM.
Because of using two different buses for interfacing RAM and ROM, the execution and processing become very fast. For fetching data or code it has not to wait until one is finished it can process simultaneously.