answersLogoWhite

0


Best Answer

There are many different ways to program microcontrollers. In fact, the question can even have two meanings:

  • how do you write software for a microcontroller?

  • how do you store your software as program code inside the microcontroller's memory?

Step one is to learn the features of the controller by examining the datasheet. A microcontroller is usually a nearly-complete system in itself. Peripherals in the hardware perform (or help the software perform) specific tasks. These are usually accessed with internal registers available to the CPU.

Next, make sure the design is achievable using the chosen microcontroller. If it is, design the software to accomplish the goal. This can be as simple as a procedural sequence of commands, or as complex as creating a real-time operating system (RTOS) capable of running multiple tasks under tight timing constraints.

Write the code in the chosen language. The CPU of a microcontroller, or any digital CPU, only understands its own language, "machine language." This is simply a sequence of bits (arranged as bytes and words) that drive the internal state machines in the CPU. A step above this is assembly language, which is usually as close to machine language as programmers get. Programmers use mnemonics in place of specific bit sequences, and provide the necessary parameters to create each machine language command. I don't know of any modern microcontroller that does not at least have an assembler. Above that are compiled languages, such as C. These take programming abstractions one more step, allowing for a single line of code to correspond to much more than one machine language step. At this level, function libraries are used to provide reusable code with different parameters. Interpreters are occasionally used in microcontrollers also.

Once the code has been created, it will need to be stored where the microcontroller expects it. Many modern microcontrollers are flash-based. This means that the software is stored in flash memory inside the microcontroller IC. Some are still EPROM-based, where the memory can be written electronically but must be erased by exposing the silicon die of the IC to ultraviolet light. Others may have no internal program memory and rely on external flash or EPROM. Some even have bootloaders, where a given set of code starts up and looks for the actual program somewhere off-chip (in memory ICs) or even off-board (transmitted over a serial communications link).

Flash-based microcontrollers are usually "in-system programmable." This means that you can connect a device to a computer and to the microcontroller board, and download code to the microcontroller. The process usually involves sending multiple short segments of code to the microcontroller, which writes that segment to its program storage memory. Then the microcontroller is reset and it boots from the new code. The device and the computer software to download code is often provided by the manufacturer of the microcontroller, or other third-party providers.

User Avatar

Wiki User

16y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you program a micro controller?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you dump any program code on micro controller 89c51?

In order to dump any program code onto a micro controller for a 89c51, you would first have to find access to the main controller board of the item, and plug the program code directly into that.


Is it possible to program micro controller by using c?

yes


How Write a program to control a drilling machine using micro-controller?

yes


Why you are using this atmel 89s52 micro controller?

because in atmel .............it is easy to program and troubleshooting


Who introduced the micro controller?

Dr. Glassenhigmer invented the micro controller


Difference between avr micro controller and 8051 micro controller?

constructed on a single chip is called micro processor constructed on a single board is called micro controller


Is it possible to write a program using a micro-controller such that it can read the time and operate at a given time?

Yes.


Is a micro-controller hardware?

Yes, a micro-controller is hardware. It is the hardware that the firmware and/or software.


What is the main difference between micro controller and fpga?

micro controller is software and fpga is hardware


How micro controller differs from micro processor?

micro controller contain system on chip memory, timers,counters where as a micro processor doesn't contain all these


What type of micro controller is AT89S52?

Its an I\O controller


Is microprocessor is a micro-controller?

no. opposite