Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

C Microcontroller tutorial?

Status
Not open for further replies.

Marks256

New Member
Does anyone have a good tutorial for learning micros with c? I am just going to be blunt; i hate assembly (all forms. that is what has kept me from finishing my z80 system... [sorry Nigel :D])

if i have to order some more free samples from MicroChip, i will be glad to do so :)p)

Oh, and any advice on what the BEST microcontrollers to start with are? I just really want to get through some proof-of-concept things, then i want to start experimenting on my own...
 
For pay (~$40). Peter Anderson's hardware stuff is good value for the money. I have to assume the C tutorial is good too. He's not a web designer, so don't be put off by the ugly site:
https://www.phanderson.com/icd/tutorial.html

Free:
**broken link removed**
**broken link removed**

EDIT: BTW, to everyone reading this, Peter Anderson's $2.50 Morgan Logic Probe's are very good, especially considering the dirt cheap price.
 
Last edited:
I hate to say BASIC for getting your feet wet, but I'll say it. I've been using Swordfish BASIC SE (the free student editon) for about 3 weeks now with its editor (not MPLAB) and it's structured language and fantastic editor are IMHO a great way to get your feet wet. (I'm sounding like gramo)

Although I agree with Nigel that you should be familar with ASM. The problem is it's a steep learning curve and I'm sure many potential newcomers get discouraged quickly when they can't get that LED to flash.

C is in the long run the "right" language, it's the one that'll get you a job in embedded programming as it's what the industry uses.

There are no shortcuts, and each language has strengths and weaknesses.
Here's the order I'm presenting them in the book.

BASIC (Compiler)
+Simple to understand
+Can get a program running in less than an hour

MPASM (Assembler)
+Smallest, fastest and not that hard really
+You'll start thinking about your problems the way the PIC sees them
+Can be put "inline" with BASIC & C when needed

C (C18, if you want to work with PICs in C skip the 12bit and 14bit cores)
+Librarys (USB, Ethernet, etc...)

Peter Anderson has started to switch to the Arduino and the PICaxe... Too bad, Peter built lots of 1-wire based kits, relay boards etc, I wish he made the code available. Ah well 2008 is almost here and I've got some kits lined up and I'll always post the source code if it's available.

Not really fond of microcontrollers with embedded languages on them. BASIC Stamp, PICAxe, Arduino, DIOSpro, etc...
 
Last edited:
blueroomelectronics said:
Although I agree with Nigel that you should be familar with ASM.
You know I agree with that. As much as people dislike asm, once you get started it's really not so difficult. And it gets you right to the hardware, so you can understand what's really going on without the high-level-language insulation. If you don't want to know what's going on in the hardware, microcontrollers probably aren't for you.

Any C programmer, IMHO, really should learn assembly language first. Learn what's really happening in there before getting on with the metaphors.

And yes, if you've never programmed before, BASIC is a good way to get basic programming concepts into your head.
 
Last edited:
People are fearful of C because they think it is not easy to use like basic.

Mostly a bunch of bull. Basic was an easy language when it ran on a text based micro, mini, or main frame. It has become a better language since then. It is no longer a basic/easy language.

Toss in the complexities of uC's in general and where does that put you.

In short if you have the ability to learn the needed uC concepts (including ASM) you have the ability to understand the simple syntax that is C.

One problem is the lack of good free tutorials.

In the mean time Prof Peter Anderson's are some of the best text based ones I seen for programming a PIC (16F877) in C. They are worth the few $ he is asking and the money goes back to helping his students. But keep in mind that they do not teach you how to program in C but rather how to program a PIC in C using the demo version of the CCS compiler.

There is the option to learn programming first using a PC in either C or BASIC. After you have a decent mastery of the language, then learn to program a uC using it. This is a much better way to go. If somwhat slower.
 
i learned QBASIC in 6th grade just for the fun of it. I have been using it ever since, but i came to realize that BASIC is dieing, and i am still looking for "the perfect language"

I would learn assembly if i have the learning tools available. I don't like to read and learn, i like to listen/watch/get my hands dirty right away. Now, to be fair, i DID learn QBASIC from tutorials, but a good chunk of my learning came from sample source code (and a lot of cut/paste code). I really can't find "good source code" to learn from. Yes, i am probably blind (i am sure some of you are screaming right now "GOOGLE IT!") But google is the problem. :( I cannot find any tutorials that are good enough for me. I want one that is structured for people with previous programming experience, but offers the simplicity needed for such a device.

edit: also, i am kinda short on the $$, so free would be great... :eek:
 
Last edited:
In that case get the Anderson tutorials.

They are the sort of thing where in the first few tutorials you make things beep and flash LEDs.

Not too much latter you are doing ADC conversions and using counter/timers.

It is good stuff because he knows his stuff.
 
but it costs money. :( :eek: :(

i don't mean to be whiney, but i am already going to be in debt until i am like 50....
 
Marks256 said:
Does anyone have a good tutorial for learning micros with c? I am just going to be blunt; i hate assembly (all forms. that is what has kept me from finishing my z80 system... [sorry Nigel :D])

It's OK, I've always thought your Z80 ideas were entirely imaginary, as well as pointless! :p
 
I've got an old Southern Cross Z80 board and a 68HC708 developers kit, I should put them on eBay.
**broken link removed**
Yep even mine has that funky keypad
 
Marks256 said:
i learned QBASIC in 6th grade just for the fun of it. I have been using it ever since, but i came to realize that BASIC is dieing, and i am still looking for "the perfect language"

I would learn assembly if i have the learning tools available. I don't like to read and learn, i like to listen/watch/get my hands dirty right away.
edit: also, i am kinda short on the $$, so free would be great... :eek:

Well Swordfish SE, C18 SE and MPASM are free.
MPLAB free includes a simulator free.

What are you waiting for?
 
I am looking for a TUTORIAL. If you were to put your z80 development board on ebay, let me know. As long as you take Money Order, i would buy it in a heart beat. ;)

Nigel said:
It's OK, I've always thought your Z80 ideas were entirely imaginary, as well as pointless!

I agree, but i just wanted to see if i could. I did have a fully functioning base system made, but i never got around to programming it, so i disassembled it for the breadboard space... :(
 
Well I've only got the board like in the photo. It powers up and squeaks. Appears the documentation was eaten by a Grue.
I can take Paypal, but I was going to see what it's worth via eBay as I've no idea what it goes for.
PS unless you're a collector avoid the SC1, punching in hex codes on a keypad is even old school for me (and I DID that 30yrs ago). Save your money and buy a proper/modern demo board...
 
I don't put much stock in the idea that a person needs to learn assembly first.

You need to understand the architecture, and a basic idea of how assembly instructions work to get an idea of what is easy for the compiler to do and what isn't. Past that, I really don't see what all a thorough understanding of asm does for someone coding in C. Not unless you wanna do some mixed C & asm.

For example, a generic "C" book won't go through the difference between RAM and ROM space because that's not part of the language, it's a microcontroller hardware issue.

I've never tried to do C on the PIC16 but I don't especially recommend it. The hardware's not really C-friendly and there are more C compilers for the PIC18 so I'm recommending the PIC18 (or dsPIC if you really wanna see some action). You can download a free MCC18 compiler for the PIC18 from Microchip, or a free C30 dsPIC compiler.
 
Oznog said:
...I've never tried to do C on the PIC16 but I don't especially recommend it. The hardware's not really C-friendly and there are more C compilers for the PIC18 so ...

I agree that the PIC16 is not an easy target for C compilers. I have been using the CCS C compiler, it works well and is very easy to use. Generates fairly dense code.

The PIC18 is a much better choice given that the cost is nearly the same.
 
Very few languages were designed with I/O in mind let alone Harvard architecture.
FORTH might be a good microcontroller language, APL not so much.
 
No it's not quite the same.
On microcontrollers, the compiler needs to diverge from the basic C spec by doing all sorts of things with #pragmas. Microchip's C18 is kinda heavy on those.
 
blueroomelectronics said:
Very few languages were designed with I/O in mind let alone Harvard architecture.
FORTH might be a good microcontroller language, APL not so much.

FORTH is a terrible microcontroller language, as it's stack based - not much use on a PIC, or any controller with limited stack size.

I used FORTH a LONG time ago, never liked it, and never really saw it as any good?.
 
Nigel Goodwin said:
FORTH is a terrible microcontroller language, as it's stack based - not much use on a PIC, or any controller with limited stack size.

I used FORTH a LONG time ago, never liked it, and never really saw it as any good?.

Obscure
JAL
Pascal (I actually liked Pascal on the PC, Alice Pascal was helpful and now free)
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top