This is for those who are completely new to programming micro controllers. using C language Here i try to give a head start to such people.
[ compile the code (F7) after saving the file as anyname.c]
There you are done with your first C program for an embedded microcontroller. You will have to set the target as AVR simulator for debugging and stepping through your code.
I will not put more stuff here since that will take away the fun part from you.
What can you do?
In later posts i will try to explain the significance of #include in embedded code.
Please leave your comment. You can subscribe to this blog by using the links under "Subscribe" section.
- First choose a platform to work on. I suggest going for the AVR. AVR microcontrollers are relatively cheap and a fairly powerful. The best part however, is that you can test a multitude of the microcontrollers'' features using just the simulator provided in the IDE. You can download it from here free of cost after a small registration.
- Now you have to download a compiler. Please note that IDE is different from compiler. I have seen this misconception very strong among freshers who have used Turbo C compiler for a long time. A compiler is more often than not a command line utility. IDE ( Integrated Development Environment) help us by managing the files and abstracting from us complex commandline arguments that are needed to compile your code. Download WINAVR.
- Please install WINAVR first and then AVRStudio. This will ensure that AVRStudio automatically picks up the WINAVR path.
- Use the GUI to guide you and create a simple project. There are many samples available. However, the wizard is very helpful. You can choose any microcontroller to start with.
- create a simple file with just the following code
int main(void)
{
int i =0;
int j = 5;
i = i + j + 100;
return 0;
}
{
int i =0;
int j = 5;
i = i + j + 100;
return 0;
}
[ compile the code (F7) after saving the file as anyname.c]
There you are done with your first C program for an embedded microcontroller. You will have to set the target as AVR simulator for debugging and stepping through your code.
I will not put more stuff here since that will take away the fun part from you.
What can you do?
- Try to write a program to add two number and store the output in a global variable.
- Other simple C programs without any printf or scanf statments.
In later posts i will try to explain the significance of #include in embedded code.
Please leave your comment. You can subscribe to this blog by using the links under "Subscribe" section.
No comments:
Post a Comment