NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » MCU specific C programming

January 12, 2011
by tomroth
tomroth's Avatar

It is easy to find tutorials on programming in C. I want a good tutorial on MCU specific C programming. I know that each MCU has its own register names and such, but a "basic" how-to, more detailed than the one included with the kit, would be helpful. As an example, ADCSRA |= (1<<ADSC) from the nerd kit, is not really explained that it is a left shift (I think). I just want a more detailed, general MCU programming guide. Am I crazy for asking this?

Thanks!

Tom

January 13, 2011
by bretm
bretm's Avatar

There may be a couple of reasons why tutorials like that are less common. First, the general idea of using shifts and OR's, like in ADCSRA |= (1 << ADSC), isn't MCU-specific C programming. It's done in general-purpose C programs as well.

The other problem is that a lot of this stuff is compiler- or library-specific. Some other things that seem MCU-specific, like "ISR(TIMER0_COMPA_vect)" are actually specific to the avr-libc code library, so it's not only MCU-specific, not only AVR MCU-specific, it's specific to one particular compiler for one particular brand of MCU. Besides avr-gcc, there's the ImageCraft compiler, the CodeVision compiler, etc.

Nevertheless, they are out there. A good place to look is AVR Freaks tutorials forum. For example they have an article on Bit Manipulation. There are a bunch more.

January 15, 2011
by mrkvickasteve
mrkvickasteve's Avatar

please list some of these tutorials because I would like to get more involved with my project. I appreciate any help you can give me with this, steve

January 15, 2011
by Hexorg
Hexorg's Avatar

Here's a good list of all possible C operations, like left shift and more. It's a good reference. :)

Post a Reply

Please log in to post a reply.

Did you know that one NerdKits customer discovered that his hamster ran several miles in a night using his kit and a Hall-effect sensor? Learn more...