Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Getting started with Microprocessor programming in C/C++

Status
Not open for further replies.

tahirsengine

Member level 3
Joined
May 7, 2007
Messages
66
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Location
Germany
Activity points
1,929
Hi,
I hope this post finds you all good in health.

I have recently got a job(after years). This job requires me to develop FPGA based systems. Now the thing is I already have experience with Verilog programming(mostly Xilinx) and board development for FPGA based systems. Now I need to learn programming NIOS II microprocessor and developing NIOS II based systems, also.

But, I dont know how to program any microprocessor.. :cry:

I know C/C++(learned at university). I also took a course on microprocessor architectures(only learned Intel 80XX series, with not programming) years ago.

I am trying to learn things, but still I need someone to guide me properly, like what files I should write, what files will be required for what e.g. command parser or initializers etc(I just know the names of these files). The company as well as I, are in a fix now, that the company has only me, and I don't have any body :smile:

Finally, decided to post here. Please treat me as complete novice to microprocessor programming.
I just need some good start, and "things to cover" knowledge.

All suggestions are warmly welcome.
Guys, please help.

Thanks in advance.
Wish you a happy progressive day.
 

MCU programming and 'big' computer programming are basically the same. the language and constructs are the same but you have to be aware of the limitations of a microprocessor. The main ones are:

1. There is no operating system, unless you are specifically including one so passing parameters into main() is pointless as there is nowhere to get the parameters from.

2. likewise, there is nowhere for the program to return to when it finishes so it has to be written to work in a self-contained loop.

3. Memory is probably restricted so you have to be more careful about data types and use them to best advantage. Using an 'int' when a 'char' is adequate will for example waste at least one byte and possibly more.

4. Microcontrollers for the most part, read logic levels on pins and write logic levels back to pins so you have to get used to working with single bit operations. It's much the same as working on bigger systems but you need to be aware that the bits are stored as component parts of bytes and you can't write a byte to a single pin.

5. Most MCUs have interrupt systems so you may have to write an interrupt service routine and be aware of the consequences of it being called at awkward times during main program flow. Usually this is nothing more than temporarily storing critical data or registers then restoring it again afterwards but sometimes you have to cater for the additional delays the ISR might cause.

As you are familiar with C/C++ you should find it fairly easy as long as you note the caveats above. Personally, I find it far more rewarding to write for MCUs than large systems.

Brian.
 
I know C/C++(learned at university). I also took a course on microprocessor architectures(only learned Intel 80XX series, with not programming) years ago.

If you are really starting out in the world of programming embedded systems, it is important to be aware that C and C++, although sharing a lot of their genomes, are languages with different purposes.

The 'C' is simplest, and may suffice for most the needs, not incidentally many compilers for microcontrollers are made for this language only.

The C++ in other hand, being a language designed to support object oriented, it is intended to optimize resourses usage on bigest systems which share runtime libraries, but require more hardware resources from the system to do the same job that could be done with C, and for that reason, unless it is really necessary to make use of more a powerful (and complicated) programming language, get started with C.
 
If you are really starting out in the world of programming embedded systems, it is important to be aware that C and C++, although sharing a lot of their genomes, are languages with different purposes.

The 'C' is simplest, and may suffice for most the needs, not incidentally many compilers for microcontrollers are made for this language only.

The C++ in other hand, being a language designed to support object oriented, it is intended to optimize resourses usage on bigest systems which share runtime libraries, but require more hardware resources from the system to do the same job that could be done with C, and for that reason, unless it is really necessary to make use of more a powerful (and complicated) programming language, get started with C.

Thank you sir for reply.
Can you please point out some good resources or tutorials about Embedded C, which are based on an IDE as well, so that I am having a complete taste of embedded C?
 

There are many family of Microcontroller. Each of them needs some special instructions to do the stuff. C is very good for small system + where time optimization and fast programm is needed. I have worked with two family of microcontroller till now. They are AVR and PIC. For learning to write code for AVR series there is a excellent book. Search google for: Elliot Williams Make AVR Programming Learning to Write Software for Hardware. For PIC family there is a great book also. Search: PIC microcontroller and Embaded System by Muhammad Ali Mazidi. In youtube search "NewbieHack Microcontroller Tutorial" which is gold... Hope this helps.
 

    V

    Points: 2
    Helpful Answer Positive Rating
I recommend to get an Evaluation Board with a microcontroller of interest.
E.g. with Nios II Embedded Evaluation Kit you will get User Guide, Design Examples, Demos that you can build from sources and then program your micro.
 

If you are really starting out in the world of programming embedded systems, it is important to be aware that C and C++, although sharing a lot of their genomes, are languages with different purposes.

The 'C' is simplest, and may suffice for most the needs, not incidentally many compilers for microcontrollers are made for this language only.

The C++ in other hand, being a language designed to support object oriented, it is intended to optimize resourses usage on bigest systems which share runtime libraries, but require more hardware resources from the system to do the same job that could be done with C, and for that reason, unless it is really necessary to make use of more a powerful (and complicated) programming language, get started with C.


Is there any need of having good knowledge of data structure and advance C (comprising process,thread,command line argument).
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top