Starting with microcontrollers

This is a discussion on Starting with microcontrollers within the Tech Board forums, part of the Community Boards category; I've always dreamed about building stuff, mechanical stuff, electric stuff...R2D2 Starwars podracer army of robots with laserguns ... STUFF! Since ...

  1. #1
    Lean Mean Coding Machine KONI's Avatar
    Join Date
    Mar 2007
    Location
    Luxembourg, Europe
    Posts
    444

    Starting with microcontrollers

    I've always dreamed about building stuff, mechanical stuff, electric stuff...R2D2 Starwars podracer army of robots with laserguns ... STUFF!

    Since I'm more of the programming type and less of the electronic type (I was always pretty bad in electronic), I thought I would try to do a project using a micro controller to build a Binary Clock. I know that you can do the exact same thing without any controller, entirely with an integrated circuit but since I'm planing on doing more advanced things, micro controllers are just what I want.

    The problem is I don't know where to start. I have no idea what I need, what types of micro controllers there are and how I can program them. I am "of course" using google at this very moment and reading through a bunch of tutorials but I was wondering if some of you know some quality resources that cover in great detail, for absolute beginners, tutorials about creating something from scratch.

    I don't think that I'll have any problems programming the controller, that's not what I'm worrying about. I'm having just slight problems figuring out how the micro controller is used to ... light an LED or make a motor move etc.

  2. #2
    Registered User
    Join Date
    Aug 2006
    Posts
    99
    Well, if you are looking for development hardware boards, take a look at Z-World stuff.

    For excellent general purpose microcontrollers, look at this introduction to Microchip devices, and some of their MCU's.

  3. #3
    Lean Mean Coding Machine KONI's Avatar
    Join Date
    Mar 2007
    Location
    Luxembourg, Europe
    Posts
    444
    I was hoping for an easy understandable tutorial about C programmable micro controllers, with a small guide about how to connect it to the components and install the IDE, compile and load it on the controller.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,671
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by KONI View Post
    I was hoping for an easy understandable tutorial about C programmable micro controllers, with a small guide about how to connect it to the components and install the IDE, compile and load it on the controller.
    I keep hoping for one too.

    Off the top of my head, look for Dev Kits. Some families to consider are Atmel AVR, TI MSP430, Microchip PIC, some 8051 derivative, or even some of the old Motorola HC08 or HC12 chips.

    I think I had the easiest startup with the MSP430 out of that bunch. And TI's documents are refreshingly done well in comparison to a number of vendors.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  6. #6
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    605
    http://www.lpctools.com/index.asp?Pa...WPROD&ProdID=2 - about $59

    Comes with a code-size limited evaluation version of Keil uVision IDE & compiler, along with a bunch of get-you-started projects.

    http://www.8052.com is a good place to ask questions, and they have some good tutorials.

    Signed an 8051 evangelist
    Visit entropysink.com - It's what your PC is made for!

  7. #7
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    605
    Oh, and if you're new to embedded C - better get used to

    Code:
    void main ()
    Visit entropysink.com - It's what your PC is made for!

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,671
    why?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #9
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    605
    What would you return the int to?
    Visit entropysink.com - It's what your PC is made for!

  10. #10
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,671
    Why do you think you have a main() at all?

    Yes, I am being pedantic.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  11. #11
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    605
    I have no idea. It was a tongue-in-cheek comment. I do all my micro programming in assembler, not C. However, most C 8051 code I've ever looked at uses void main(), and I've always figured it's because

    a) there's no OS to return anything to (which I've always been told is why we use int main() )

    b) effectively an embedded application never terminates, so when would you return anything anyway.

    Tell you what, enlighten me. Why would you use int main() in an embedded app? I'm genuinely interested by the way, not trying to be an ass (OK, maybe I was in the original post ).

    Also, maybe we should continue this in a seperate thread so as not to derail the OP's.
    Last edited by RobR; 05-13-2007 at 03:23 AM. Reason: Bad spelling makes me look retarded
    Visit entropysink.com - It's what your PC is made for!

  12. #12
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    In some TI DSP stuff I was once working with, your actual code did not start until main returned.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  13. #13
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    605
    Quote Originally Posted by Dave_Sinkula View Post
    In some TI DSP stuff I was once working with, your actual code did not start until main returned.

    Surely that's just semantics though? Main by a different name? I'm a bit out of my depth here, by the way.
    Visit entropysink.com - It's what your PC is made for!

  14. #14
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    No. AFAIR DSP/BIOS ran after main was finished. It was more or less the system initialization. You set up the registers, etc. in main, and after it returned things ran. It was actually rather cool.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  15. #15
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,671
    Embedded platforms usually fall into the "freestanding" category.
    Quote Originally Posted by draft c99
    5.1.2.1 Freestanding environment
    1 In a freestanding environment (in which C program execution may take place without any
    benefit of an operating system), the name and type of the function called at program
    startup are implementation-defined. Any library facilities available to a freestanding
    program, other than the minimal set required by clause 4, are implementation-defined.
    2 The effect of program termination in a freestanding environment is implementation-defined.
    Essentially, all bets are off as to what you name the first function, what parameters it takes and what it returns, should it return at all.

    You have to RTM to find out what is needed for the environment in which you're working.

    If you're genuinely working without an OS, then main is probably the thing which gets called, which loops forever, and returns void.
    If you have an RTOS present, there could be many tasks, none of which are called main, but they do loop forever and return void.

    > Why would you use int main() in an embedded app?
    Hypothetically speaking, taking Dave Sinkula's example, one could imagine a scenario which determines if initialisation was successful or not.

    But you're right, the vast majority of such embedded 'task' functions loop forever and return void.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Programing microcontrollers in c
    By gorabhat in forum C Programming
    Replies: 2
    Last Post: 09-09-2008, 10:40 AM
  2. Interpreter.c
    By moussa in forum C Programming
    Replies: 4
    Last Post: 05-28-2008, 05:59 PM
  3. i am not able to figure ot the starting point of this
    By youngashish in forum C++ Programming
    Replies: 7
    Last Post: 10-07-2004, 02:41 AM
  4. question about reading inputs starting with 0
    By jibbles in forum C Programming
    Replies: 8
    Last Post: 08-09-2004, 03:27 AM
  5. 8051 microcontrollers
    By ygfperson in forum Tech Board
    Replies: 5
    Last Post: 12-02-2002, 11:29 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21