Discuss Programing microcontrollers in c in the C Programming forum on Dev Shed. Programing microcontrollers in c C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
Take your business to the next level, with "The
Edge of Success: 9 Building Blocks to Double Your Sales."
Inside, you will discover how to easily capture more leads,
get repeat sales, and significantly grow your business.
Posts: 5,959
Time spent in forums: 2 Months 3 Weeks 2 Days 12 h 46 m 36 sec
Warnings Level: 10
Number of bans: 1
Reputation Power: 0
You don't normally connect the micro to your PC unless your PC is part of an emulator or, perhaps, drives circuity for blowing the ROM portion (if any).
Your PC might have as an application a cross-compiler. In that case you would write the program using the cross-compiler and blow the resultant code into ROM or download it to the microcontroller's RAM, perhaps.
I would suggest that you have a fair amount of research to do regarding microprocessors/microcontrollers, memory, I/O devices, etc.
For a learning environment you might want to get an existing set of hardware. Google single-board computers, or similar.
Location: Glendale, Los Angeles County, California, USA
Posts: 8,737
Time spent in forums: 1 Month 2 Weeks 3 Days 3 h 18 m 17 sec
Reputation Power: 3271
Post the title of the book here and we'll tell you if it is useless or not.
By the way, most microcontrollers come with a development kit (cross-compiler/simulator/flash programmer/remote debugger) and accompanying hardware to program it. Each one of them is different and depends on the manufacturer. For instance, I cannot use a PIC development kit to program an ATMEL processor.
You need to decide first on which specific manufacturer and device you're going with and only then worry about the rest of the details.
__________________ Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne Diary of a first time dog owner <-- my cousin's blog
Posts: 4,127
Time spent in forums: 3 Weeks 6 Days 3 h 46 m 21 sec
Reputation Power: 1540
Quote:
Originally Posted by gorabhat
I have recently download a book on programing microcontrollers in c
Provide a link. The subject matter of the book may determine the appropriate advice. 'microcontroller' covers a wide range of devices from tiny 8 or even 4 bit devices with very small memories running as < 10MHz up to sophisticated 32bit devices with MMU, cache, and megabytes of memory. The equipment you need to get started depends entirely on the target you will be using. Choose that first.
The easiest way to start is to get a development board for the part you wish to use. Often these are sold as 'evaluation kits' that provide all you need to get started. Certainly the board vendor will be able to advise. You may need an in-circuit emulator or JTAG debugger or similar to program and debug the part, other boards can be programmed and (and in some cases debugged) over serial or USB by having the necessary bootstrap firmware built into the device at the factory.
Some part vendors provide free tools, some make you pay, others use usually expensive tools from third-parties. Many parts have code-size limited versions of the necessary tools to get you started. In many cases free GNU tools ara available or for some 8bit architectures the open source SDCC toolchain.
What might be best is for you to describe what application you which to create with the device, and what your budget is (you will almost certainly have to spend some money) then it would be easier to advise. If you already have a board, tell us what it is.
It may also be possible to direct you to a more specific forum once you have an idea what you are doing.
Posts: 8
Time spent in forums: 1 h 6 m 36 sec
Reputation Power: 0
Thanks for your reply clifford
But seriously speaking i know nothing about microcontroller programming
i am just curious about that how it can be programmed by C language
so i just check out the book & its simply goes over my head
so in sort i have no idea about what i am going to make
Posts: 4,575
Time spent in forums: 1 Month 2 Weeks 1 Day 20 h 30 m 36 sec
Reputation Power: 1238
Quote:
Originally Posted by gorabhat
Hi guys
I have recently download a book on programing microcontrollers in c
But i couldn't get any idea about the microcontroller & how to connect it to my PC
So please someone describe the basic idea about programing microcontrollers using C language & the hardware & software needed for it
Thanks in advance
The concept, very basically and in general terms, is that microcontrollers are the CPUs of embedded devices. Your microwave oven has a microcontroller in it that is programmed to run the microwave and the controls. Modern cars have a number of microcontrollers that run it. Your DVD player does too. The original IBM PC keyboard was run by an embedded device, an Intel 8048, and I'm sure that subsequent keyboards also contain microcontrollers. And just about everything else we use -- the vast majority of microcontroller applications are transparent to us.
As already told you by the others, you would use a development kit to develop the software for a microcontroller. Most are chip sets that your hardware designers would need to incorporate into their design, but some come on more-or-less self-contained modules (eg, daughter-boards that can be attached to a motherboard) or even as a single-board computer (SBC) whose peripheral connectors would attach to whatever they're controlling.
They will read the software you design for them from some form of non-volative memory, most likely some form of ROM, EROM, or flash. That software will need to run as a stand-alone system, so it will need to link in run-time libraries, start-up code, etc, that will be provided by the development kit. You will develop the software on your PC and then download it to the non-volatile memory that the device will use.
Once you've developed the embedded device, there's no problem with connecting it to your PC, provided you had included that option in your design. It's very common for a device to connect to a PC through a serial port or a USB port. You could even design an option card that plugs into the motherboard's bus. It's whatever you design it to be.
Posts: 4,127
Time spent in forums: 3 Weeks 6 Days 3 h 46 m 21 sec
Reputation Power: 1540
Quote:
Originally Posted by gorabhat
i am just curious about that how it can be programmed by C language
You'll need some kit. There are inexpensive ways of getting what you need if you are good with a soldering iron. You still failed to mention your budget, but here's one option that will make it fairly painless to get started PIC C Programming Tutorial Pack. The advantage of this is that it includes some useful I/O modules so you can do something 'interesting'.
You might be better off not using a PIC at all. It leaves a lot to be desired as a C programming platform, and is relatively expensive in terms of tool costs. It is also not so well served by the hobbiest community. Consider the Atmel AVR: more powerful, designed to run C code, broader range of parts with greater consistency between variants, so what you learn on one AVR is generally good for another. Start at AVR Freaks. Its in-system programming and on-chip debug capabilities mean that the programming and debug hardware is cheap and simple to build yourself. A similar package to that above for the PIC is available atjust $59 that's less than 1/5th the cost of the PIC system! I got that link from AVR Freaks, there are many others.
There is a good free AVR toolchain from WinAVR if you decide to assemble your own kit of parts. If you want to spend no money, use WinAVR with Atmel's free AVR studio which includes an AVR simulator so you can run code without hardware. A good way to get started, if a little uninteresting. See AVR freaks for more ideas.
Clifford
Last edited by clifford : September 10th, 2008 at 04:09 AM.
Reason: typo
Location: Glendale, Los Angeles County, California, USA
Posts: 8,737
Time spent in forums: 1 Month 2 Weeks 3 Days 3 h 18 m 17 sec
Reputation Power: 3271
While the exact procedure depends on what CPU you're using, here's the general process:
1. Your microcontroller generally has a different CPU than your PC, hence you'll need a compiler that outputs machine code for the CPU on the microcontroller. Since the microcontroller generally has limited system resources, most people write their C code on a PC and use a cross-compiler. All the cross-compiler does is that it runs on a PC, but writes out the executable with machine code for the microcontroller's CPU.
2. Now that you have your executable, the next thing to do is to transmit it to your microcontroller's board so it can run your program. Generally this involves plugging a programmer module onto your PC. Some boards already have the programming attachment, so you can directly plug it to your PC via a serial cable.
3. Sometimes your executable may need other libraries or it may require the program to be placed in a particular memory location on the microcontroller board. In such cases, you usually have a relocater tool or a program to make a flash image suitable for loading on to the microcontroller.
4. Now you have a program that transmits the flash image to the microcontroller via the interface. After this is done, the program on the microcontroller can run independently.
Hope this helps.
Note: In general, when you write a program in C, the compiled code on Atmel processors is smaller and takes fewer instructions to run the code than the same C code compiled for PIC or Intel (at least in my experience. Your mileage may vary)
Posts: 4,127
Time spent in forums: 3 Weeks 6 Days 3 h 46 m 21 sec
Reputation Power: 1540
Here's and interesting PIC Simulator and its Windows port. It can perform whole board simulation including external peripherals, and can be instrumented with a virtual oscilloscope.
Forest Electronics - also includes a simulator, free version is 2K word limited. There's also a free ebook for use with this tool, and they sell inexpensive hardware if you decide to progress past the simulator. This is a great tool, with 'visual' RAD style application development for predefined peripheral hardware/software blocks. I'd suggest that this is a good all-in-one solution for you to test the waters without spending a penny.
Create the Optimal Architecture for your Critical Applications Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.
Gartner Magic Quadrant for Application Delivery Controllers Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.
Knowledge is Power What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.
Rationalizing the Multi-Tool Environment The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.