Register to reply

How much of C do you have to know before programming microcontrollers?

by pyroknife
Tags: microcontrollers, programming
Share this thread:
pyroknife
#1
Jan18-13, 09:29 PM
P: 417
I'm learning C on my own time. I'm going at a pretty fast pace, but I'm highlighting most of the important things or at least, what I think is important so I can refer back to it later. I struggle with most of the back of the chapter exercises mainly because I'm going through it really fast and most of the time, I have to end up looking at the solutions.

How much of C do you have to know before you start programming microcontrollers for basic circuits needs such as controlling the elements in a circuit, motors, etc... Not too advanced programming stuff, but stuff that requires programming.

I'm like 3/4 of the way through the book and I can see where some of this would apply, but if I were given a microcontroller and told to program it so it would behave (control a circuit) a certain way, I wouldn't even know where to start.

Specifically, I am interested in using an Arduino and PIC
Phys.Org News Partner Engineering news on Phys.org
Research project on accident-avoiding vehicle concluded
Smaller artificial magnetic conductors allow for more compact antenna hardware
Autonomy expert led team in developing "self-flying planes"
berkeman
#2
Jan18-13, 10:11 PM
Mentor
berkeman's Avatar
P: 41,258
Which C book? Are you reading K&R?

I would think you are good to go. Once you have the basics (especially bitwise operations and logical operations), that's most of what you need. Depending on what you want to do, arrays will help. Eventually you will want to be comfortable with pointers, but not for initial uC programming, IMO.
rbj
#3
Jan18-13, 10:52 PM
P: 2,251
you better get some of the microcontroller basics. like how the peripherals are done. are the periphs memory mapped? or are they special MPU registers?

anything that is memory mapped, you should be able to manipulate with instructions in C. but if these periphs are special internal registers, then only the MPU assembly language can get to it. you should at least have an idea how your development system connects C routines to assembly routines.

C is pretty low level, but it is not assembly language and you might need both for development.

Runei
#4
Jan18-13, 11:06 PM
P: 140
How much of C do you have to know before programming microcontrollers?

Really understanding uControllers reauires 3 things from my point of view

- Hardware knowledge
- Programming knowledge
- Usage knowledge

What I mean by this is that a person wanting to work with microcontrollers has to have some kind of knowledge about the CPU architecture and the memory layout. This means

- Some basic courses in computer architecture.

- If you really wanna work it you gotta know about how to set up the microcontroller, most times this means understanding how a bootloader works, or bootstrap, in terms of assembler language (specific to the CPU architecture). This will allow you to create drivers for all the peripherals in C language.

- If the usage of your microcontroller is going to be very specific, your programming is going to be specific (means drivers, and higher applications will be centered around the usage)

- If the usage of your microcontrolller is going to be general, you will need to analyze the different systems that your controller must interact with, and create drivers that can handle dynamic interaction with these devices.

Edit: Controlling motors etc.
My field is about control systems, and while many people see controlling motors etc., as an inexact science, there is alot you can learn from studying first classical control theory and then digital control theory.

Those two subjects will give you the best engineering understanding of how to achieve your goals.
pyroknife
#5
Jan18-13, 11:29 PM
P: 417
Thanks for all the responses.

I am using Kochan's "Programming in C" book. I started using K&R's, but they do expect you to know some of the basics, which I didn't know.

I am actually a MECH major. We're doing a project for the mechatronics class this coming semester. I'm not sure what the exact details are yet. These are projects made up by individuals, so each project will vary. For ours, I am not sure how complicated the coding will be.
gnurf
#6
Jan19-13, 10:06 AM
P: 330
Quote Quote by pyroknife View Post
How much of C do you have to know before you start programming microcontrollers for basic circuits needs such as controlling the elements in a circuit, motors, etc... Not too advanced programming stuff, but stuff that requires programming. [...] Specifically, I am interested in using an Arduino and PIC.
I agree with berkemanójust go for it. The best way to learn programming microcontrollers in C is to program microcontrollers in C. Find a simple LED blinking code snippet, copy it to your project, compile, download and see that it works. Once you've done that, you can start modifying the code and expand it to do more interesting stuff. There's enough Arduino/PIC/Atmega code out there now that will allow you to do almost anything. I wouldn't worry too much about assembly language and what not at this stage. Just get a system up and running (which is easy) and take it from there.
pyroknife
#7
Jan21-13, 01:53 PM
P: 417
How important is objective based programming and Debugging for programming microcontrollers?

There's a chapter in my book called "objective oriented programming" and another called "Debugging Programs."

How importnat are these 2 things when it comes to programming microcontrollers like PICs and Arduinos?
nsaspook
#8
Jan21-13, 09:56 PM
P: 663
Quote Quote by pyroknife View Post
How important is objective based programming and Debugging for programming microcontrollers?

There's a chapter in my book called "objective oriented programming" and another called "Debugging Programs."

How importnat are these 2 things when it comes to programming microcontrollers like PICs and Arduinos?
For most small micro-controller programming projects OOP is overkill because the amount of global data/program structure is small, machine resources are limited and the micro-controller usually operates at the task level. The OOP paradigm is just not very useful at this level.

Debugging micro-controllers is a very important subject that usually requires specialized knowledge of the hardware/software tool environment used to develop programs for the devices and is normally supplied by the manufacturer.
Abstr7ct
#9
Jan22-13, 04:10 AM
P: 17
I have a Microcontroller and Microprocessor course that I will take a semester later. I've finished the prerequisite, which is Digital Design I, and I'm looking forward to prepare myself to the Microcntroller course before I take it. What would you recommend me to do? I'm thinking of learning programming in Assembly and C and getting an Arduino Uno board. Give me an advice.

This is the description of the Microcontroller course in my college:

This is an introductory course in designing microcontroller-based embedded systems. Topics include an overview of a single-chip microcontroller, hardware and software concepts in microcontroller, system architecture, central processing unit (CPU), internal memory (ROM, EEPROM, RAM, FLASH), Input/ Output ports, serial communication, programmable interrupts, ADC, DAC, interfacing and timers, microcontroller programming model and instruction set , assembly and C language programming. Labs and projects are essential parts of this course and students are expected to spend a considerable time in laboratory work.


Register to reply

Related Discussions
PIC Microcontrollers Engineering, Comp Sci, & Technology Homework 1
Programming pic microcontrollers using assembly language Electrical Engineering 1
Teach yourself kit on how to use capacitors and resistors Electrical Engineering 4
Difference between a microcontroller and a microprocessor? Electrical Engineering 2
Want to get into microcontrollers Electrical Engineering 8